basic register

This commit is contained in:
Matteo Rosati
2026-01-26 00:36:05 +01:00
parent 54141eb91a
commit 4b93f0c7f7
12 changed files with 217 additions and 44 deletions

13
src/utilities/password.ts Normal file
View File

@@ -0,0 +1,13 @@
export const hashPassword = async (password: string): Promise<string> => {
const PASSWORD_SALT = Bun.env.PASSWORD_SALT!;
const saltedPassword = PASSWORD_SALT + password;
const encoder = new TextEncoder();
const data = encoder.encode(saltedPassword);
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((b) => b.toString(16).padStart(2, "0"))
.join("");
return hashHex;
};