PHP MD5哈希

问题描述:

我在C#中的哈希算法,简单地说,它是:PHP MD5哈希

string hashCode = string.Empty; 
     if (null != password) 
     { 
      System.Security.Cryptography.MD5 cryptography = new System.Security.Cryptography.MD5CryptoServiceProvider(); 
      byte[] code = cryptography.ComputeHash(Encoding.Default.GetBytes(password)); 
      StringBuilder stringBuilder = new StringBuilder(); 

      // Converting the code to string. 
      for (int i = 0; i < code.Length; i++) 
      { 
       stringBuilder.Append(code[i].ToString("x2")); 
      } 

      hashCode = stringBuilder.ToString(); 
     } 

     return hashCode; 
    } 

现在我需要复制在PHP这种行为..... 在此先感谢...

注意:我无法更改C#的行为,因为它已经实现,密码保存在我的数据库中使用此算法。

+0

什么是你的问题?你想让我们为你写代码?或者你想要一些指针?另外,使用SHA代替MD5进行加密。 – 2011-03-11 05:13:30

+2

伙计们,请MD5不加密。 – TomTom 2011-03-11 05:30:36

+0

PHP用一个简单的md5(“你的字符串在这里”)函数开箱即用 – Infotekka 2011-03-11 05:33:26

PHP内置了MD5能力,你可以放入任何东西并得到一个十六进制字符串,这是你想到的吗?

MD5()

http://php.net/manual/en/function.md5.php

见下文

Encryption in PHP