ASP.NET MVC 3 app, BCrypt.CheckPassword failing

后端 未结 3 1472
我寻月下人不归
我寻月下人不归 2021-01-14 04:23

I\'m working on implementing security in an ASP.NET MVC 3 application, and am using the BCrypt implementation found here to handle encryption and verification of passwords.

3条回答
  •  余生分开走
    2021-01-14 05:03

    HttpUtility.HtmlDecode() is used when the user is created, before the password is originally hashed:

    Password = Password.Hash(HttpUtility.HtmlDecode(registration.Password)),
    

    However, HttpUtility.HtmlDecode() is not used when later when comparing password to hash, in

    var authorized = _repository.CredentialsAreValid(HttpUtility.HtmlDecode(login.username), login.password);
    

    Perhaps a slight change to:

    var authorized = _repository.CredentialsAreValid(HttpUtility.HtmlDecode(login.username), HttpUtility.HtmlDecode(login.password));
    

    I realize this is an older question but I'm contemplating using BCrypt and this question raised a potential flag for me so I'm interested in knowing if this resolves this issue. I apologize, I'm not in a position at the moment to verify my answer, but I hope it helps.

提交回复
热议问题