Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v2 (legacy)verifyPassword

verifyPassword

The verifyPassword function compares a plain text password against a hashed password, either using bcrypt for hashed comparisons or directly comparing plain text passwords.

Works in: Node.js, React JS, HTML5

ParameterTypeDefaultDescription
stringPasswordstringundefinedThe plain text password to verify.
hashedPasswordstringundefinedThe hashed password to compare against.
isHashedbooleanfalseIndicates whether the provided password is already hashed. Default is false.

Usage

Example: Verify Plain Text Password

const plainTextPassword = 'Password123'; const hashedPassword = '$2a$10$SJVY.s8OD3S1D3HJh3n3MeI8yzUmJm0bO5L2R3Z78b8MWg8L4NLqG'; nfsfu234FormValidation.verifyPassword(plainTextPassword, hashedPassword) .then(isMatch => { console.log("Passwords Match: ", isMatch); // true or false }) .catch(error => { console.error("Error verifying password: ", error); });

Example: Verify Hashed Password

const plainTextPassword = 'Password123'; const hashedPassword = '$2a$10$SJVY.s8OD3S1D3HJh3n3MeI8yzUmJm0bO5L2R3Z78b8MWg8L4NLqG'; nfsfu234FormValidation.verifyPassword(plainTextPassword, hashedPassword, true) .then(isMatch => { console.log("Passwords Match: ", isMatch); // true or false }) .catch(error => { console.error("Error verifying password: ", error); });
Last updated on