日期:2014-05-17  浏览次数:20488 次

关于.net 加密MD5的问题
怎么实现md5的加密与解密过程。。。。

------解决方案--------------------
md5解密?
md5单向加密,没法解密
还是用des吧
------解决方案--------------------
1.MD5严格来说是哈希算法而非加密算法,所以MD5理论上不可逆,也不存在所谓的逆向和解密
2.如何使用MD5随便一搜就有,MSDN的示例就有……
------解决方案--------------------
MD5加密是不可逆的,适合将密码加密后存在数据库

想实现双向,自己定义规则也可以
------解决方案--------------------
md5加密简单
加密比如:
C# code

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 有个匹配加密解密的库
------解决方案--------------------
探讨

引用:
md5加密简单
加密比如:

C# code

public string md5(string str, int code)
{
if (code == 16)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5"……

------解决方案--------------------
探讨
怎么实现md5的加密与解密过程。。。。

------解决方案--------------------
都说了 md5是不可逆的加密
你可以用 可逆的 偏移量 加密方式
------解决方案--------------------
C# code

//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();    
}