/// <summary>
/// MD5 字符串加密
/// </summary>
/// <param name="str">需要加密的字符串</param>
/// <returns></returns>
public static string StringToMD5(string str)
{
byte[] b = Encoding.Default.GetBytes(str);
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(b);
StringBuilder sb = new StringBuilder();
foreach (byte bt in result)
sb.Append(bt.ToString("x2"));
return sb.ToString();
}
/// MD5 字符串加密
/// </summary>
/// <param name="str">需要加密的字符串</param>
/// <returns></returns>
public static string StringToMD5(string str)
{
byte[] b = Encoding.Default.GetBytes(str);
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(b);
StringBuilder sb = new StringBuilder();
foreach (byte bt in result)
sb.Append(bt.ToString("x2"));
return sb.ToString();
}