Skip to content

TypeScript API / laikacms/crypto / hashPassword

Function: hashPassword() ​

ts
function hashPassword(password, rounds?): Promise<string>;

Hash a password using bcrypt with post-quantum secure defaults.

Security considerations:

  • Uses minimum 12 rounds (2^12 iterations) for quantum resistance
  • Validates input length to prevent DoS attacks
  • bcrypt's 72-byte limit provides natural protection against very long passwords

Note: While bcrypt is not quantum-resistant in the cryptographic sense, its computational cost makes brute-force attacks expensive even with quantum speedups (Grover's algorithm provides only quadratic speedup for symmetric operations).

Parameters ​

ParameterTypeDefault valueDescription
passwordstringundefinedPlain text password to hash
roundsnumberPASSWORD_CONSTANTS.MIN_ROUNDSNumber of salt rounds (default: 12, minimum: 12)

Returns ​

Promise<string>

Promise resolving to the hashed password

Throws ​

Error if password is invalid

Released under the MIT License.