diff --git a/src/util/id.ts b/src/util/id.ts new file mode 100644 index 0000000..ce1bf08 --- /dev/null +++ b/src/util/id.ts @@ -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"); +} diff --git a/src/util/types.d.ts b/src/util/types.d.ts new file mode 100644 index 0000000..149eb17 --- /dev/null +++ b/src/util/types.d.ts @@ -0,0 +1 @@ +declare type Omit = Pick>;