C# MD5字符串文本加密
作者:C/S框架网|www.cscode.ne  发布日期:2021-03-19 14:54:11
  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



上一篇 下一篇