HASH_HMAC
Function • Misc changes in PHP 8.2
Generate a keyed hash value using the HMAC method.
hash_hmac Function synopsis
hash_hmac(
string $algo,
string $data,
string $key,
bool $binary = false
): string
Parameters
$algo
Typestring
Name of selected hashing algorithm (e.g. "sha256").
For a list of supported algorithms see hash_hmac_algos.
$data
Typestring
Message to be hashed.
$key
Typestring
Shared secret key used for generating the HMAC variant of the message digest.
$binary
OptionalTypeboolDefault valuefalse
When set to true, outputs raw binary data.
false outputs lowercase hexits.
Return value
Typestring
Returns a string containing the calculated message digest as lowercase hexits
unless $binary is set to true in which case the raw
binary representation of the message digest is returned.
Changes to the HASH_HMAC Function
PHP 8.2
- Attribute added for parameter
$key:#[SensitiveParameter]
PHP 8.0
- Return type added:
string - Parameter type added for parameter #1 (
$algo):string - Parameter type added for parameter #2 (
$data):string - Parameter type added for parameter #3 (
$key):string - Parameter name of parameter #4 changed:
$raw_outputto$binary - Parameter type added for parameter #4 (
$binary):bool - Parameter default value added for position #4 (
$binary):false
hash_hmac(
- $algo,
+ string $algo,
- $data,
+ string $data,
- $key,
+ string $key,
- $raw_output
+ bool $binary = false
- )
+ ): string HASH_HMAC Function Availability
HASH_HMAC Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Future Release | Yes |
| PHP 8.5Upcoming Release | Yes |
| PHP 8.4Supported (Latest) | Yes |
| PHP 8.3Supported | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Security-Fixes Only | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |