[英]i am creating login api and hashed password using bcrypt
I want to create a register login logout system.我想创建一个注册登录注销系统。 at time of registration i am taking email and password and storing hashed password.
在注册时,我正在使用 email 和密码并存储散列密码。 now when logging in i want to compare password entered to hashed password.
现在登录时我想将输入的密码与散列密码进行比较。 so basically I want to know how can I compare and check plain password with hashed passwords
所以基本上我想知道如何比较和检查普通密码和散列密码
I think this is a duplicate question but am not able to mark it as such.我认为这是一个重复的问题,但无法将其标记为这样。
This should work, taken from the bcryptJS docs .这应该可行,取自bcryptJS docs 。
Sync同步
// Load hash from your password DB.
bcrypt.compare(myPlaintextPassword, hash, function(err, result) {
// result == true
});
Promise Promise
// Load hash from your password DB.
bcrypt.compare(myPlaintextPassword, hash).then(function(result) {
// result == true
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.