引用:

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();
}
}
}

posted on 2015-08-06 11:07  邢帅杰  阅读(143)  评论(0编辑  收藏  举报