From 025dbf0ebb7f30a23c355dc21240997c834939ad Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 9 Sep 2023 01:38:01 -0400 Subject: [PATCH] Fix ID hashing and add color generator --- src/util/id.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/util/id.ts b/src/util/id.ts index ce1bf08..af869b3 100644 --- a/src/util/id.ts +++ b/src/util/id.ts @@ -6,5 +6,21 @@ export function createID() { } export function createUserID(ip: string) { - return createHash("sha-256").update(ip).update(env.SALT).digest("hex"); + return createHash("sha256") + .update(ip) + .update(env.SALT) + .digest("hex") + .substring(0, 24); +} + +export function createColor(ip: string) { + return ( + "#" + + createHash("sha256") + .update(ip) + .update(env.SALT) + .update("color") + .digest("hex") + .substring(0, 6) + ); }