你好,我需要一些关于这个问题的帮助。我已经搜索了解决方案,但还没有找到。
我想比较两个相同密码的 bcrypt 哈希密码,该怎么做?
例如:
我有这两个哈希密码,它们都来自相同密码的 bcrypt:
var password = E@Js#07Do=U$
var hash1 = $2a$10$fKAyjaG0pCkisZfRpKsBxursD6QigXQpm1TaPBDZ4KhIZRguYPKHe
var hash2 = $2a$10$mgApOcRIp7RSK3lRIIlQ5e/GjVFbxAFytGAEc0Bo17..r8v2pPR22
// that's not working for me
bcrypt.compare(passwordHash, userPasswordLoginHash, function(err, isMatch) {
if (err) throw err;
if(isMatch){
console.log('correct password!')
}
callback(null, isMatch);
});
我该如何使用bcryptjs npm包来比较它们以确定它们是否来自同一个密码?