引用:
using System.Security.Cryptography;
类:
public class MD5Util
{
public static string GetMD5(string input)
{
return GetMD5(input, Encoding.Default);
}
public static string GetMD5(string input, Encoding encoding)
{
using (MD5 md5Hash = MD5.Create())
{
byte[] data = md5Hash.ComputeHash(encoding.GetBytes(input));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sb.Append(data[i].ToString("x2"));
}
return sb.ToString();
}
}
}