简体   繁体   English

我正在使用 bcrypt 创建登录 api 和散列密码

[英]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.

相关问题 如何使用 bcrypt 在寄存器中散列的密码检查登录密码? - How to check check the password from login with the password hashed by bcrypt in register? 如何使用散列 bcrypt 版本更新数据库中的每个密码? - How Can I update each password in my database with hashed bcrypt version? 我在使用 bcrypt 比较时遇到问题。 我在注册页面上成功输入了 hash 密码,但在登录页面上我没有成功比较。 请帮忙:) - I am having a problem with bcrypt compare. I succed to hash password on Register page, but I not to compare successfully on login page. Please help :) 当我在客户端 hash 我的密码时,我没有得到散列字符串,而是得到密码本身 - when I hash my password on the client side , I am not getting the hashed string instead getting the password itself 如何验证使用随机盐进行哈希处理的密码? - How do I verify a password which is hashed using a random salt? bcrypt.js 如何知道散列密码与明文密码相同? - How can bcrypt.js know that the hashed password is the same as the plain text password? 未能将散列密码密码与 node.js 中的 bcrypt.js 进行比较 - failing to compare hashed password password with bcrypt.js in node.js 为什么即使两个密码字符串完全匹配,我也会从 bcrypt 比较中得到 isMatch null? - Why am I getting isMatch null from bcrypt compare even though two password string matches perfectly? 使用 API 创建天气应用程序,我正在尝试显示图标 - Creating a weather app using API and I am trying to show the icon 我正在创建一个登录-注销演示 - i am creating a login- logut demo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM