I want to have a Encryption using SHA1. My Code is
public static string EncryptPassword(string password)
{
try
{
SHA1 sha1 = new SHA1Managed();
var bytehash = sha1.ComputeHash(new MemoryStream(new ASCIIEncoding().GetBytes(password)));
var stringhash = new ASCIIEncoding().GetChars(bytehash).ToString();
return stringhash;
}
catch (Exception ex)
{
// Some Exception....
}
return null;
}
It's not working. It only return System.Char[]. What am I doing wrong in this
Because that's what ToString() returns from an array of chars...
try
new string(new ASCIIEncoding().GetChars(bytehash));
and choose Maurice's answer, which is smarter ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With