FormsAuthentication.HashPasswordForStoringInConfigFile(md5, "MD5")
.net自带md5加密方法默认字符集是utf-8的我现在想用gb2312字符集加密这个方法能改吗
要是不能求一个。net的md5加密字符集能设置成gb2312的方法
------解决方案--------------------------------------------------------
System.Security.Cryptography.MD5CryptoServiceProvider对象的ComputeHash方法来进行加密:
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
Response.Write(BitConverter.ToString(MD5.ComputeHash(Encoding.GetEncoding("gb2312").GetBytes("木子屋"))).Replace("-", ""));
------解决方案--------------------------------------------------------
static string getMd5Hash(string input)
{
MD5 md5Hasher = MD5.Create();
byte[] data = md5Hasher.ComputeHash(Encoding.GetEncoding("gb2312").GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}