hash_hmac_file

FunctionMisc changes in PHP 8.2

Generate a keyed hash value using the HMAC method and the contents of a given file.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2
Changed
PHP 8.3
PHP 8.4
PHP 8.5
PHP 8.6

hash_hmac_file Function synopsis

hash_hmac_file(
    string $algo,
    string $filename,
    string $key,
    bool $binary = false
  ): string|false

Parameters

$algo

Typestring

Name of selected hashing algorithm (e.g. "sha256"). For a list of supported algorithms see hash_hmac_algos.

$filename

Typestring

URL describing location of file to be hashed; Supports fopen wrappers.

$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|false

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. Returns false if the file $filename cannot be read.

Changes to the hash_hmac_file Function

PHP 8.2

PHP 8.0

  • Return type added: string|false
  • Parameter type added for parameter #1 ($algo): string
  • Parameter type added for parameter #2 ($filename): string
  • Parameter type added for parameter #3 ($key): string
  • Parameter name of parameter #4 changed: $raw_output to $binary
  • Parameter type added for parameter #4 ($binary): bool
  • Parameter default value added for position #4 ($binary): false
  hash_hmac_file(
-     $algo,
+     string $algo,
-     $filename,
+     string $filename,
-     $key,
+     string $key,
-     $raw_output
+     bool $binary = false
-   )
+   ): string|false

hash_hmac_file Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported 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