using (MD5 md5 = new MD5CryptoServiceProvider())
{
StringBuilder sb = new StringBuilder(32);
var res = md5.ComputeHash(Encoding.UTF8.GetBytes(value));
for (int i = 0; i < res.Length; i++)
{
sb.Append(res[i].ToString("x2"));
}
return sb.ToString();
}
或者
using (MD5 md5 = new MD5CryptoServiceProvider())
{
var res = md5.ComputeHash(Encoding.UTF8.GetBytes(value));
return Convert.ToBase64String(res);
}
谢谢