.NET sha1.ComputeHash加密十六进制数组在PHP中等效

时间:2013-09-24 12:54:01

标签: php .net encryption sha1

如何在PHP中重新创建此.NET哈希?

byte[] bH = Encoding.UTF8.GetBytes(sT);
SHA1 sha1 = SHA1.Create();
byte[] hB = sha1.ComputeHash(bH);
StringBuilder hS = new StringBuilder(hB.Length * 2);
foreach (byte b in hB) {
   hS.AppendFormat("{0:x2}", b);
}
finalValue = hS.ToString();

1 个答案:

答案 0 :(得分:1)

答案:

$finalValue = sha1($sT);