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
| Parameter | Type | Default value | Description |
|---|---|---|---|
password | string | undefined | Plain text password to hash |
rounds | number | PASSWORD_CONSTANTS.MIN_ROUNDS | Number of salt rounds (default: 12, minimum: 12) |
Returns
Promise<string>
Promise resolving to the hashed password
Throws
Error if password is invalid