basic register
This commit is contained in:
13
src/utilities/password.ts
Normal file
13
src/utilities/password.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user