Skip to content

hashPassword

function hashPassword(password): Promise<string>;

Defined in: src/auth/basic.ts:62

Hash a password with scrypt and a fresh random salt.

The returned string is self-describing and safe to store in config or a database: scrypt$<saltHex>$<hashHex>. Pass it back to verifyPassword (or supply it as a user’s passwordHash) to check a candidate password.

Parameter Type
password string

Promise<string>

const stored = await hashPassword("correct horse battery staple");
// → "scrypt$<32 hex chars>$<128 hex chars>"