hash_hmac()


string hash_hmac(string $algo, string $data, string $key [ , bool $raw_output = false ] )

Description

hash_hmac() generates a keyed hash value using the HMAC method

※ available F/W version : all

Parameters

Return values

Returns a string containing the calculated message digest.

Example

<?php
$data = "abcdefghijklmn";
$key = "0123456789";

$hash_value = hash_hmac("md5", $data, $key, true);

hexdump($hash_value);
// OUTPUT: 0000  4d 2b 59 a5 12 ab 3c 0c  78 98 94 5a 13 97 86 50  |M+Y...<.x..Z...P|
?>

See also

hash() / hash_init() / hash_update() / hash_final()

Remarks

hash_hmac() is identical to PHP group’s hash_hmac function. However, it supports only "md5", "sha1" and "sha256" algorithm.

※ "sha256" algorithm is only available on the firmware version 1.3.1 and later versions.