I’m trying to compare two passwords , one from DB and other is user entered. The one from db is hashed and stored in binary format. So I have to conver it to string before comparing.
console.log(
user.PasswordHash.toString('base64') ===
'$2a$10$UZptbo5h4lQFYmK352CPf.jDvPZh1pm3uC3Nb0wEVjF/RUCw2OU2G'
); //false
When I look in console user.PasswordHash.toString(‘base64’) evaluates to $2a$10$UZptbo5h4lQFYmK352CPf.jDvPZh1pm3uC3Nb0wEVjF/RUCw2OU2G
which is the same value.
What is happening?
bcrypt.compareSync(
password,
user.PasswordHash.toString('base64')); //false
Any help is appreciated.