CKTIS / PHP
hash_hmac()
Overi bajte sporočila s skrivnim ključem in kriptografsko zgoščevalno funkcijo.
Različica: PHP 8.4; repository runtime, production runtime not attested
Sintaksa
hash_hmac(string $algo, string $data, string $key, bool $binary = false): stringOveri bajte sporočila s skrivnim ključem in kriptografsko zgoščevalno funkcijo. Privzeto dobimo šestnajstiško besedilo z malimi črkami, s true pa surove bajte. Neznan ali nekriptografski algoritem v PHP 8 sproži ValueError. Preverjanje zahteva isti ključ in zapis.
Podpis
hash_hmac(string $algo, string $data, string $key, bool $binary = false): string
Izhod primera
[32,true,false]
Primeri
<?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]