I have stumbled across the below snippet, which encrypts a user's password. This is what i want to do because I don't want to store the user's password in the database without any encryption.
This is working fine for what I want to achieve, but my question is this: how can I un-encrypt it to make sure the value they have entered in the password box matches?
// Hash the password details of the user!
private static string CreatePasswordHash(string pwd, string salt)
{
string saltAndPwd = string.Concat(pwd, salt);
string hashedPwd =
FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd, "SHA1");
hashedPwd = string.Concat(hashedPwd, salt);
return hashedPwd;
}
I call the above like this
string password = CreatePasswordHash(TxtPassword.Text, "1579");
The password then becomes something like this: 566DAB495AD0747B49865F9177E430DFAD63CA281579
So how do I un-encrypt that?
Thank you for your time.
Rfc2898DeriveBytesfor password hashing, and notHashPasswordForStoringInConfigFileRfc2898DeriveBytesis a class.