本文介绍了如何使用BCrypt验证密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查用户输入的密码是否与其他人哈希并存储到数据库的密码匹配.通常您会使用这个权利吗?:
How do I check if a user entered password matches a password that has been hashed and stored into a database by somebody else. Normally you would use this right?:
bool value = BCryptHelper.CheckPassword("Tom123", passwordHash);
那么,如果您没有包含哈希密码的passwordHash变量,该怎么办?
So what if you don't have the passwordHash variable which contains the hashed password?
我对BCrypt的工作原理不甚了解,所以我想我丢失了一些非常简单的内容.
I don't have a great understanding of how BCrypt works so I think I am missing something very simple.
推荐答案
以下是答案的提示.您可以点击链接以获取更多详细信息.
Here is a hint to the answer. You can follow the link for further detailed information.
string salt = BCryptHelper.GenerateSalt(6);
var passwordHash= BCryptHelper.HashPassword("Tom123", salt);
bool value = BCryptHelper.CheckPassword("Tom123", passwordHash);
这篇关于如何使用BCrypt验证密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!