/opt/canhelp/node_modules/better-auth/dist/crypto
NameSizeModeActions
buffer.d.mts2830644editdlrm
buffer.mjs6230644editdlrm
buffer.mjs.map12100644editdlrm
index.d.mts14070644editdlrm
index.mjs34020644editdlrm
index.mjs.map59760644editdlrm
jwt.d.mts6600644editdlrm
jwt.mjs37360644editdlrm
jwt.mjs.map79900644editdlrm
password.d.mts3120644editdlrm
password.mjs11170644editdlrm
password.mjs.map19300644editdlrm
random.d.mts2450644editdlrm
random.mjs2720644editdlrm
random.mjs.map3600644editdlrm
Edit: /opt/canhelp/node_modules/better-auth/dist/crypto/password.mjs (1117B)
import { constantTimeEqual } from "./buffer.mjs"; import { BetterAuthError } from "@better-auth/core/error"; import { hex } from "@better-auth/utils/hex"; import { scryptAsync } from "@noble/hashes/scrypt.js"; import { hexToBytes } from "@noble/hashes/utils.js"; //#region src/crypto/password.ts const config = { N: 16384, r: 16, p: 1, dkLen: 64 }; async function generateKey(password, salt) { return await scryptAsync(password.normalize("NFKC"), salt, { N: config.N, p: config.p, r: config.r, dkLen: config.dkLen, maxmem: 128 * config.N * config.r * 2 }); } const hashPassword = async (password) => { const salt = hex.encode(crypto.getRandomValues(new Uint8Array(16))); const key = await generateKey(password, salt); return `${salt}:${hex.encode(key)}`; }; const verifyPassword = async ({ hash, password }) => { const [salt, key] = hash.split(":"); if (!salt || !key) throw new BetterAuthError("Invalid password hash"); return constantTimeEqual(await generateKey(password, salt), hexToBytes(key)); }; //#endregion export { hashPassword, verifyPassword }; //# sourceMappingURL=password.mjs.map