确认使用的bcrypt版本是否正确。首先,确保你已正确安装了BCrypt 组件,并且使用的是稳定的、最新的版本。可以使用Nuget管理安装最新版本的BCrypt;
确认Bcrypt密码是否正确。在验证时,确保要验证的加密密码和存储在数据库中的密码是匹配的。当两者不匹配时,验证会失败,无论其它环境是否正确;
确认密码是否为空。如果密码参数为空,验证将失败。确保未传递一个空的密码值。
以下是代码示例:
using BCrypt.Net;
// verify the password hash with the user input password
if (BCrypt.Net.BCrypt.Verify(password , user.Password))
{
// login success
}
else
{
// login fail
}