【发布时间】:2019-09-12 01:57:25
【问题描述】:
您好,在我搜索解决方案后我需要一些帮助来解决这个问题,但我还没有找到,
我想将 2 个哈希密码与相同密码的 bcrypt 进行比较, 我该怎么做?
例如:
我有这 2 个哈希密码来自 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 包?
【问题讨论】:
-
我认为您只能将纯文本密码与散列密码进行比较
标签: javascript node.js hash passwords bcrypt