MD5 hashing
.NET base class library is very rich. Here is the code snippet which hashes the give data. It’s recommended to store the hash of the sensitive data like user’s password.
public static string GetMD5Hash(string data)
{
System.Text.Encoder enc = System.Text.Encoding.ASCII.GetEncoder();
byte[] bs = new byte[data.Length];
enc.GetBytes(data.ToCharArray(), 0, data.Length, bs, 0, true);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(bs);
return System.BitConverter.ToString(result).Replace("-", "").ToLower();
}