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

passwordMatch

The passwordMatch function checks if a plain text password matches a hashed password. It can use bcrypt for hashed comparisons or directly compare 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

(async () => { try { const stringPassword = 'Password123'; const hashedPassword = '@Password123'; const isMatch = await nfsfu234FormValidation.passwordMatch(stringPassword, hashedPassword); console.log("Passwords Match: ", isMatch); // true or false } catch (error) { console.error("Error verifying password: ", error); } })();

Example: Verify Hashed Password

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

See also

Last updated on