mirror of
https://github.com/JonasunderscoreJones/accounts.jonasjones.dev.git
synced 2025-10-24 11:29:18 +02:00
fixed functions
This commit is contained in:
parent
aae42227f7
commit
5c93a8de7a
1 changed files with 6 additions and 9 deletions
15
src/index.js
15
src/index.js
|
|
@ -214,17 +214,14 @@ async function hashPassword(password) {
|
|||
const data = encoder.encode(password);
|
||||
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
||||
return bufferToHex(hashBuffer);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
return hashHex;
|
||||
}
|
||||
|
||||
async function verifyPassword(password, storedHash) {
|
||||
const hash = await hashPassword(password);
|
||||
return hash === storedHash;
|
||||
}
|
||||
|
||||
function bufferToHex(buffer) {
|
||||
const byteArray = new Uint8Array(buffer);
|
||||
return Array.from(byteArray, byte => byte.toString(16).padStart(2, '0')).join('');
|
||||
async function verifyPassword(password, hash) {
|
||||
const hashedPassword = await hashPassword(password);
|
||||
return hashedPassword === hash;
|
||||
}
|
||||
|
||||
function formatDate(date) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue