0

如何通过 php 编写此代码并获得类似的结果?

为 SHA 计算构建 MSG

 MSG_TXT = "8F"+"08"+"1234567890123470"+"08"+"1234567890123470"+"0743210987654321"+"08"
 Convert MSG_TXT to MSG_BIN [] = {$8F,$08,$12,$34,$56, ..... $65,$43,$21,$08}
 SHA-1(MSG_BIN[]) = 9E667331662BE10D78D56F75D6899F764212C5C1

这段代码在delphi中工作,但在php中没有类似的结果

4

1 回答 1

0

尝试这个:

// your string
$txt = "8F"."08"."1234567890123470"."08"."1234567890123470"."0743210987654321"."08";
// convert to binary string
$txt = pack('H*', $txt);
// print sha1
echo sha1($txt, false);
于 2012-08-11T01:22:29.503 回答