mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
20 lines
570 B
JavaScript
20 lines
570 B
JavaScript
let _scryptMod
|
|
let _enc = new TextEncoder
|
|
|
|
let _getScrypt = () =>
|
|
_scryptMod ||= import("https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm")
|
|
.then(m => (m.scrypt && m) || m.default || m)
|
|
|
|
let _toHex = u8 =>
|
|
Array.from(u8, b => b.toString(16).padStart(2, "0")).join("")
|
|
|
|
async function hashPassword(password, salt) {
|
|
let { scrypt } = await _getScrypt()
|
|
let pw = _enc.encode(password)
|
|
let sa = _enc.encode(salt)
|
|
let hash = await scrypt(pw, sa, 1024, 8, 1, 32)
|
|
return _toHex(hash)
|
|
}
|
|
export default hashPassword;
|
|
// Generation time: 13.034s
|
|
// Result: PASS
|