Skip to content

TypeScript API / laikacms/crypto / verifyPassword

Function: verifyPassword() ​

ts
function verifyPassword(password, hash): Promise<boolean>;

Verify a password against a hash with timing attack protection.

Security considerations:

  • Always performs a comparison operation to maintain constant time
  • Validates inputs before processing
  • Uses dummy hash comparison when inputs are invalid to prevent timing leaks

Parameters ​

ParameterTypeDescription
passwordstringPlain text password to verify
hashstringHashed password to compare against

Returns ​

Promise<boolean>

Promise resolving to true if password matches, false otherwise

Released under the MIT License.