日期:2014-05-17 浏览次数:20597 次
public string md5(string str, int code)
{
if (code == 16)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
if (code == 32)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
}
return "00000000000000000000000000000000";
}
------解决方案--------------------
解密可以通过接受的 字符进行加密后 再和原有数据比较,
------解决方案--------------------
XMD5 有个匹配加密解密的库
------解决方案--------------------
//winform
public static string StringToMD5Hash(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();
}