C# 2005 Md5加密后 怎么跟 asp Md5加密不一样!

来源:百度知道 编辑:UC知道 时间:2024/09/23 13:17:39
C# 2005 Md5加密后 怎么跟 asp Md5加密不一样!

有没有朋友,能给个正确的,加密后一样的代码..

是一样的

C# 取中间16位,与ASP相同

public static string Md5(string inputString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(inputString));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < encryptedBytes.Length; i++)
{
sb.AppendFormat("{0:x2}", encryptedBytes[i]);
}
return sb.ToString().Substring(8, 16);
}

是因为字符的编码不一样改成一样的编码就行了,看看这吧
http://zhidao.baidu.com/question/103185401.html