0
這裏匹配是.NETPHP加密不是用asp.net加密
public string GetMD5Hash(string name) {
MD5 md5 = new MD5CryptoServiceProvider();
byte[] ba = md5.ComputeHash(Encoding.UTF8.GetBytes(name));
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba)
hex.AppendFormat("{0:x2}", b);
return Convert.ToString(hex);
}
,並在PHP我使用下面的代碼
class foobar {
public function str2hex($string) {
$hex = "";
for ($i = 0; $i < strlen($string); $i++)
$hex .= (strlen(dechex(ord($string[$i]))) < 2) ? "0" . dechex(ord($string[$i])) : dechex(ord($string[$i]));
return $hex;
}
public function GetMD5($pStr) {
$data = mb_convert_encoding($pStr, 'UTF-16LE', 'UTF-8');
$h = $this->str2hex(md5($data, true));
return $h;
}
}
$foobar = new foobar;
$nisha =$foobar->GetMD5('5698882');
echo "</br>";
echo $nisha;
但輸出的代碼與.net加密輸出不匹配 都不同
感謝您的回覆,但裏克.NET開發人員不能改變他們的代碼。有可能我們可以將上面的.net代碼複製到php中? –
你可以給我使用你的.net代碼的字符串abcdefghijklmnopqrstuvwxyz md5散列 –