User ID functions

This commit is contained in:
Hri7566 2023-09-07 19:14:20 -04:00
parent cc3a7a7b43
commit 68f445ea03
2 changed files with 11 additions and 0 deletions

10
src/util/id.ts Normal file
View File

@ -0,0 +1,10 @@
import { createHash, randomBytes } from "crypto";
import env from "./env";
export function createID() {
return randomBytes(12).toString("hex");
}
export function createUserID(ip: string) {
return createHash("sha-256").update(ip).update(env.SALT).digest("hex");
}

1
src/util/types.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;