类库需要使用md5加密方法
//需要的命名空间
using System.Security.Cryptography;
public string Encryption(string pwd)
{
MD5 md5 = MD5.Create();
StringBuilder builder = new StringBuilder();
byte[] md5Bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(pwd));
for (int i = 0; i < md5Bytes.Length; i++)
{
builder.AppendFormat("{0:X2}", md5Bytes[i]);
}
return builder.ToString();
}
----------------------------------------------------------------------------------------------------------
web Form 使用md5 加密方法
//需要的命名空间
using System.Web.Security;
public string Encryption(string pwd)
{
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5").ToUpper();
}