简体   繁体   English

nodejs - 如何比较bcrypt的两个哈希密码

[英]nodejs - how to compare two hashes password of bcrypt

Hello I need some help with this issue after I search the solution and I have not found yet,您好,在我搜索解决方案后我需要一些帮助来解决这个问题,但我还没有找到,

I want to compare 2 hash password with bcrypt of the same password, how do I do it?我想将 2 个 hash 密码与相同密码的 bcrypt 进行比较,我该怎么做?

for example:例如:

I have these 2 hash password that came from the same password in bcrypt:我有这 2 个 hash 密码,它们来自 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);
});

how can i compare them, to determine that they came from the same password, by using bcryptjs npm package?我如何比较它们,以确定它们来自相同的密码,使用 bcryptjs npm package?

Hello I need some help with this issue after I search the solution and I have not found yet,您好,我在搜索解决方案后需要一些帮助来解决这个问题,但我还没有找到,

I want to compare 2 hash password with bcrypt of the same password, how do I do it?我想将 2 个哈希密码与相同密码的 bcrypt 进行比较,我该怎么做?

for example:例如:

I have these 2 hash password that came from the same password in 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);
});

how can i compare them, to determine that they came from the same password, by using bcryptjs npm package?我如何通过使用 bcryptjs npm 包来比较它们,以确定它们来自相同的密码?

Hello I need some help with this issue after I search the solution and I have not found yet,您好,我在搜索解决方案后需要一些帮助来解决这个问题,但我还没有找到,

I want to compare 2 hash password with bcrypt of the same password, how do I do it?我想将 2 个哈希密码与相同密码的 bcrypt 进行比较,我该怎么做?

for example:例如:

I have these 2 hash password that came from the same password in 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);
});

how can i compare them, to determine that they came from the same password, by using bcryptjs npm package?我如何通过使用 bcryptjs npm 包来比较它们,以确定它们来自相同的密码?

Hello I need some help with this issue after I search the solution and I have not found yet,您好,我在搜索解决方案后需要一些帮助来解决这个问题,但我还没有找到,

I want to compare 2 hash password with bcrypt of the same password, how do I do it?我想将 2 个哈希密码与相同密码的 bcrypt 进行比较,我该怎么做?

for example:例如:

I have these 2 hash password that came from the same password in 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);
});

how can i compare them, to determine that they came from the same password, by using bcryptjs npm package?我如何通过使用 bcryptjs npm 包来比较它们,以确定它们来自相同的密码?

For a bit extra security you can encrypt the password in the front-end and decrypt and compare in the back-end为了增加一点安全性,您可以在前端加密密码并在后端解密和比较

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM