MD5加密的两种方式笔记。

第一种方式是使用:
System.Web.Security空间下的相应类和方法加密,示例:
public string GetMD5(string s,int len)
{
   
return FormsAuthentication.HashPasswordForStoringInConfigFile(s,"MD5").Substring(0,len).ToLower();
}
第二种方式:
public string GetMD5(string s,int len)
{
  System.Security.Cryptography.MD5 md5
=System.Security.Cryptography.MD5.Create();
  
byte[] bytes=System.Text.Encoding.UTF8.GetBytes(s);
bytes
=md5.ComputeHash(bytes);
return System.BitConverter.ToString(buffer).Replace("-""").Substring(0,len).ToLower();
}
原文地址:https://www.cnblogs.com/McJeremy/p/1212600.html