How to verify a password using BCrypt

帅比萌擦擦* 提交于 2019-12-13 02:07:09

问题


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);

So what if you don't have the passwordHash variable which contains the hashed password?

I don't have a great understanding of how BCrypt works so I think I am missing something very simple.


回答1:


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);

http://www.dreamincode.net/forums/blog/1267/entry-3301-c%23-using-bcrypt-in-a-net-application-why-its-better-than-sha-or-md5/



来源:https://stackoverflow.com/questions/22525091/how-to-verify-a-password-using-bcrypt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!