Get MD5

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 1163
public static string GetMD5(string key)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] byteArray = md5.ComputeHash(Encoding.Default.GetBytes(key));
StringBuilder stringBuilder = new StringBuilder(32);
for (int i = 0; i < byteArray.Length; i++)
stringBuilder.Append(byteArray[i].ToString("x").PadLeft(2, '0'));

return stringBuilder.ToString();
}

Comments or Responses

Login to post response