mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 16:47:55 +00:00
9 lines
412 B
JavaScript
9 lines
412 B
JavaScript
async function hashPassword(password, salt) {
|
|
const { scrypt } = await import('https://cdn.skypack.dev/scrypt-js');
|
|
const encoder = new TextEncoder();
|
|
const pwBuf = encoder.encode(password);
|
|
const saltBuf = encoder.encode(salt);
|
|
const hashBuf = await scrypt(pwBuf, saltBuf, 1024, 8, 1, 32);
|
|
return Array.from(hashBuf).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
}
|
|
export default hashPassword; |