![](/img/trans.png)
[英]How to check check the password from login with the password hashed by bcrypt in register?
[英]i am creating login api and hashed password using bcrypt
我想创建一个注册登录注销系统。 在注册时,我正在使用 email 和密码并存储散列密码。 现在登录时我想将输入的密码与散列密码进行比较。 所以基本上我想知道如何比较和检查普通密码和散列密码
我认为这是一个重复的问题,但无法将其标记为这样。
这应该可行,取自bcryptJS docs 。
同步
// Load hash from your password DB.
bcrypt.compare(myPlaintextPassword, hash, function(err, result) {
// result == true
});
Promise
// Load hash from your password DB.
bcrypt.compare(myPlaintextPassword, hash).then(function(result) {
// result == true
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.