This tutorial will show you how to use the ComputeHash function in C#.NET.
You can see, You can find the ComputeHash method in the classes: SHA1CryptoServiceProvider, SHA1Managed, SHA256Managed, SHA384Managed, SHA512Managed, MD5CryptoServiceProvider, SHA1, SHA256, SHA384, SHA512, MD5.
For example hash a string using MD5 encryption
public string MD5(string value)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] original = ASCIIEncoding.Default.GetBytes(value);
byte[] encoded = md5.ComputeHash(original);
return BitConverter.ToString(encoded).Replace("-", "");
}
The ComputeHash method which takes an array of bytes and returns the hash value in an array of bytes.