CKTIS / PHP
hash_hmac()
Overovací kód správy vznikne z jej bajtov, tajného kľúča a kryptografickej hašovacej funkcie.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
hash_hmac(string $algo, string $data, string $key, bool $binary = false): stringOverovací kód správy vznikne z jej bajtov, tajného kľúča a kryptografickej hašovacej funkcie. Predvolený zápis je hexadecimálny s malými písmenami, true vráti bajty. Neznámy alebo nekryptografický algoritmus v PHP 8 vyvolá ValueError. Overujte s tým istým kľúčom a formátom.
Signatúra
hash_hmac(string $algo, string $data, string $key, bool $binary = false): string
Výstup príkladu
[32,true,false]
Príklady
<?php
$tag=hash_hmac("sha256","batch=42","example-key",true);
echo json_encode([strlen($tag),hash_equals($tag,hash_hmac("sha256","batch=42","example-key",true)),hash_equals($tag,hash_hmac("sha256","batch=43","example-key",true))]);
Výsledok
[32,true,false]