Fix ID hashing and add color generator

This commit is contained in:
Hri7566 2023-09-09 01:38:01 -04:00
parent e8f1453eed
commit 025dbf0ebb
1 changed files with 17 additions and 1 deletions

View File

@ -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)
);
}