How do I check the password entered by the user? BCrypt.HashPassword(password) does not match with BD.AspNetUsers.PasswordHash.

Volk Volk 571 Reputation points
2022-07-24T21:29:11.553+00:00

Hello!

I have a website where users register. A user password is saved as a hash in BD.AspNetUsers.PasswordHash.
I have a separate proxy server that needs to verify the password entered by the user from another application.
I connect to the database of the site, try to create a hash of the password entered by the user and try find it in the database.

But this code on the server:

var hashPassword = BCrypt.Net.BCrypt.HashPassword(password);  

...creates a completely different hash of the same password for me.

How do I verify the password entered by the user on the proxy server?
Of course, I can save the real password on the site, but then why store it as a hash?

BCrypt.Net-Next.Strong Name - latest version 4.0.3. Website is on Net.core 6.

Thank you!

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,188 questions
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 26,136 Reputation points
    2022-07-26T10:16:54.553+00:00
    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Volk Volk 571 Reputation points
    2022-07-25T21:31:19.163+00:00

    It would seem that this is a standard simple function in one line, but I can't understand how to check the password by hash with BCrypt. Maybe Net.Core 6 MVC Identity System encrypt the password by other cryptographer and uses, for example user_id or something else? Then what method should I use to compare the password and what should I send there?

    Hash passwords in ASP.NET Core

    password-hashing

    0 comments No comments