Skip to content

TypeScript API / laikacms/crypto / needsRehash

Function: needsRehash() ​

ts
function needsRehash(hash, targetRounds?): boolean;

Check if a password hash needs to be upgraded to more secure parameters.

This is useful for gradually upgrading password security as users log in.

Parameters ​

ParameterTypeDefault valueDescription
hashstringundefinedThe bcrypt hash to check
targetRoundsnumberPASSWORD_CONSTANTS.MIN_ROUNDSTarget number of rounds (default: MIN_ROUNDS)

Returns ​

boolean

true if the hash should be upgraded

Released under the MIT License.