mirror of
https://github.com/JonasunderscoreJones/accounts.jonasjones.dev.git
synced 2025-10-25 03:49:19 +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 data = encoder.encode(password);
|
||||||
|
|
||||||
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
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) {
|
async function verifyPassword(password, hash) {
|
||||||
const hash = await hashPassword(password);
|
const hashedPassword = await hashPassword(password);
|
||||||
return hash === storedHash;
|
return hashedPassword === hash;
|
||||||
}
|
|
||||||
|
|
||||||
function bufferToHex(buffer) {
|
|
||||||
const byteArray = new Uint8Array(buffer);
|
|
||||||
return Array.from(byteArray, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue