public static string GetMD5(string str)
{
var md5 = System.Security.Cryptography.MD5.Create();
byte[] data = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data.ToString("x2"));
}
string s = sBuilder.ToString();
return s;
}
这个是第三方给出的解密方式:
public static string MD5Encrypt(string str)
{
string pwd = "";
MD5 md5 = MD5.Create();
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
for (int i = 0; i < s.Length; i++)
{
pwd = pwd + s.ToString();
}
return pwd;
}