C# MD5字符串文本加密
C# MD5字符串文本加密C# Code: /// <summary>
/// MD5加密,不可逆
/// </summary>
/// <param name="clearText">明文字符串</param>
/// <returns></returns>
public static string ToMD5(string clearText)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(clearText));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < encryptedBytes.Length; i++)
{
sb.AppendFormat("{0:x2}", encryptedBytes[i]);
}
return sb.ToString().ToLower();
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761