2013-07-17 48 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