CKTIS / PHP
hash_hmac()
Ovjerava bajtove poruke tajnim ključem i kriptografskom sažetnom funkcijom.
Verzija: PHP 8.4; repository runtime, production runtime not attested
Sintaksa
hash_hmac(string $algo, string $data, string $key, bool $binary = false): stringOvjerava bajtove poruke tajnim ključem i kriptografskom sažetnom funkcijom. Zadano vraća heksadekadski tekst malim slovima, a uz true sirove bajtove. Nepoznat ili nekriptografski algoritam u PHP-u 8 izaziva ValueError. Provjera traži isti ključ i format.
Potpis
hash_hmac(string $algo, string $data, string $key, bool $binary = false): string
Ispis primjera
[32,true,false]
Primjeri
<?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))]);
Rezultat
[32,true,false]