如何通过php编写此代码并获得类似的结果?
为SHA calc构建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
中没有起到类似的效果答案 0 :(得分: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);