MD5加密

 

/// <summary>
/// MD5加密,需要引用库文件using System.Security.Cryptography;
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
private string MD5Password(string password)
{
//using System.Security.Cryptography;
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] hashedDataBytes;
hashedDataBytes = md5Hasher.ComputeHash(Encoding.GetEncoding("gb2312").GetBytes(password));
StringBuilder tmp = new StringBuilder();
foreach (byte i in hashedDataBytes)
{
tmp.Append(i.ToString("x2"));
}
return tmp.ToString();
}

posted @ 2019-10-23 09:28  帝雪寒天  阅读(167)  评论(0编辑  收藏  举报