私はこれを理解しようとしているので、似たようなことができます。知っている:
buf には、ハッシュが追加された認証キーが含まれています (最後の 20 バイト)。MachineKeySection で検索されている HashData は SHA1 です。
length -= 20;
byte[] buffer2 = MachineKeySection.HashData(buf, null, 0, length);
for (int i = 0; i < 20; i++)
{
if (buffer2[i] != buf[length + i])
{
return null;
}
}
これが私が考えていることです。buf の最後の 20 バイトを除くすべてをハッシュしています。次に、作成したばかりのハッシュと buf の最後の 20 バイトに追加されたハッシュを一度に 1 バイトずつ比較します。
だからPHPで私はこれを試しています:
//get the length of the ticket -20 bytes
$ticketLn = strlen($buf)-40;
//grab all but the last 20 bytes
$ticket = substr($decrypthex, 0, $ticketLn);
//create a hash of the ticket
$hash = substr($decrypthex, $ticketLn);
そして次のステップは比較です。しかし、$hash と sha1($ticket) の出力をエコーすると一致しないので、コードでそれらを比較することさえ気にしませんでした。