verifyPassword method
Verify a password against a stored hash
password
is the plain text password to verify
hash
is the stored hash to compare against
salt
is the salt used for the hash
iterations
is the number of iterations used
keyLength
is the length of the derived key
Returns true if the password matches, false otherwise
Implementation
bool verifyPassword(
String password,
String hash,
String salt,
int iterations,
int keyLength,
) {
final computedHash = _pbkdf2(
password.codeUnits,
base64.decode(salt),
iterations,
keyLength,
);
return _constantTimeEquals(
base64.decode(hash),
computedHash,
);
}