hash_hkdf

PHP 7 >= 7.1.2, PHP 8
hash_hkdf - Generate a HKDF key derivation of a supplied key input

hash_hkdf(
     string$algo,
     string$key,
     [int$length = 0],
     [string$info = ""],
     [string$salt = ""]
): string

Parameters

algo

Name of selected hashing algorithm (i.e. "sha256", "sha512", "haval160,4", etc..) See hash_algos for a list of supported algorithms.

Note:

Non-cryptographic hash functions are not allowed.

key

Input keying material (raw binary). Cannot be empty.

length

Desired output length in bytes. Cannot be greater than 255 times the chosen hash function size.

If length is 0, the output length will default to the chosen hash function size.

info

Application/context-specific info string.

salt

Salt to use during derivation.

While optional, adding random salt significantly improves the strength of HKDF.

Return Values

Returns a string containing a raw binary representation of the derived key (also known as output keying material - OKM); or false on failure.

Exceptions and Errors

An E_WARNING will be raised if key is empty, algo is unknown/non-cryptographic, length is less than 0 or too large (greater than 255 times the size of the hash function).

Related Functions

Example of hash_hkdf

Show all examples for hash_hkdf

PHP Version:


Function hash_hkdf:

HASH Message Digest Framework Functions

Most used PHP functions