-
Notifications
You must be signed in to change notification settings - Fork 6
Password Hasher
Inside any application whenever we allow the user to create the account then he need to provide the password in plain text and if we save that password in a plain text directly inside the database then just think about it what will be happened ? If someone will gain an access of the database then he can see all the passwords of the users so in order to solve this problem it's always recommended to Hash the password before saving it inside the database.
I hope you've installed this Authentication Plugin inside your Asp.Net Core project. Well in this library or Nuget plugin you'll be able to hash the password with secure and trusted algorithms.
Let's say you've be asked to provide the password and you add your password something like Apple123! then we'll use this code to Hash the password.
string hashedPassword = SecurePasswordHasherHelper.Hash(Apple123!)
Apple123! equivalent Hash string is $DNEFSA$V10000$PMCjQg77vX6piW11bo8XKwM2dKjwMk8qOWVj25sMEonKoN2e
Remember ! Every time you hash Apple123! you'll get a different Hash string.
And to validate the password you need to add the following line of code.
if (SecurePasswordHasherHelper.Verify(Apple123!, hashedPassword))
{
// Add your logic here`
}
Authors : Asfend Yar Hamid (Microsoft MVP)