2013-07-17 47 views
0

改写这是代码PLZ帮我感谢我怎么能写MD5 .NET在PHP

public static string CalculateMD5Hash(string strInput) 
    { 
     MD5 md5 = System.Security.Cryptography.MD5.Create(); 
     byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(strInput); 
     byte[] hash = md5.ComputeHash(inputBytes); 

     StringBuilder sb = new StringBuilder(); 
     for (int i = 0; i < hash.Length; i++) 
     { 
      sb.Append(hash[i].ToString("x2")); 
     } 
     return sb.ToString(); 
    } 
+1

如果你想获得md5在php中,你可以用'md5()' –

+1

['md5()'](http://php.net/md5)怎么回事? – Maerlyn

回答

1

您可以使用md5()

<?php 
    function CalculateMD5Hash($strInput){ 
     return md5($strInput); 
    } 
?> 
+0

先生其实我想要验证它与SQL Server数据库和应用程序内置.NET当用户通过.net应用程序注册的密码创建为MD5哈希,然后附加X2哈希...当我从这个密码读取密码我的PHP应用程序它无法读取因为X2 strign被追加到.net应用程序的md5哈希,所以这是如何我可以读取这个哈希使用PHP ... – user2589964

+0

以上是.NET代码先生我想在PHP中相同的代码... – user2589964