In my Blazor server app, I'm having difficulty authenticating a user's password, after having previously created it using the same password. The example below depicts the password ("testing_01") being originally created and hashed using PasswordHasher.HashPassword. Thereafter, I attempt to verify that same password using PasswordHasher.VerifyPassword. It permanently returns the message "Login Failed". I'm clearly doing something wrong.
As I'm using the same password, I would have expected the simple example to have returned "Login Succeeded".
Thanks for the response. However, it seems your bullet-point no. 1 is incomplete? You state: "However, when you later try to verify the password in the VerifyPassword method with the salt.".
Also, in bullet-point no. 2, I'm not sure what "logic I need to verify" in the VerifyPassword method. Surely all the logic is already there in the code snippet?
Your code seems fine to me but you can debug and check some things
The issue might be related to how you generate and store the salt. In your HashPasswordWithSalt method, you generate a random salt and concatenate it with the password before hashing. However, when you later try to verify the password in the VerifyPassword method with the salt.
Check your logic in the VerifyHashedPassword method.
Brian McBridePosted Dec 1, 2023, 11:58 AM
Thanks for the response. However, it seems your bullet-point no. 1 is incomplete? You state: "However, when you later try to verify the password in the
VerifyPasswordmethod with the salt.".Also, in bullet-point no. 2, I'm not sure what "logic I need to verify" in the VerifyPassword method. Surely all the logic is already there in the code snippet?
Vijay Pratap SinghPosted Dec 1, 2023, 11:50 AM
Your code seems fine to me but you can debug and check some things
HashPasswordWithSaltmethod, you generate a random salt and concatenate it with the password before hashing. However, when you later try to verify the password in theVerifyPasswordmethod with the salt.Thanks