Generate SHA1 Hash from string
Posted on: Tue Sep 08 12:10:54 -0700 2009. Updated on: Tue Sep 08 12:13:24 -0700 2009.
Category: DotNet
Category: DotNet
Code to one way hash a string using SHA1.
public static string GenerateSHA1(string input)
{
byte[] buffer = Encoding.UTF8.GetBytes(input);
SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider();
string hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");
return hash;
}