SHA1
-
Hello sir, I have to encrypt my password.I used the following statement. string pswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text, SHA1 ); Error message is "SHA1 is a type not a variable". How can i do?
The second parameter is expecting a string not an enum. Try this:
string pswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text,
**"SHA1"**
);Kelly Herald Software Developer
-
The second parameter is expecting a string not an enum. Try this:
string pswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text,
**"SHA1"**
);Kelly Herald Software Developer
-
A hash is one way. It cannot be decrypted. However, you can just compare the newly generated hash with the one stored like below.
string storedpswd = ... // retrieve stored password from your storage location
string newpswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text, "SHA1" );
if (newpswd == storedpswd)
{
// passwords match
}else
{
// passwords do not match
}Kelly Herald Software Developer
-
A hash is one way. It cannot be decrypted. However, you can just compare the newly generated hash with the one stored like below.
string storedpswd = ... // retrieve stored password from your storage location
string newpswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text, "SHA1" );
if (newpswd == storedpswd)
{
// passwords match
}else
{
// passwords do not match
}Kelly Herald Software Developer
-
You can use TripleDES, Rijndael, or any of the non-hashing algorithms located in the
System.Security.Cryptography
namespace. Below is a link to MSDN's library for the TripleDES class and it has a complete example of how to encrypt and decrypt data. The other algorithms can also be found in the MSDN library. TripleDESCryptoServiceProvider Class[^]Kelly Herald Software Developer