Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<sodium_crypto_generichash_updatesodium_crypto_kdf_keygen>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026

sodium_crypto_kdf_derive_from_key

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_kdf_derive_from_key — Derive a subkey

Description

function sodium_crypto_kdf_derive_from_key(
    int $subkey_length,
    int $subkey_id,
    string $context,
    #[\SensitiveParameter] string $key
): string

Derive a subkey from a root key and additional context.

Similar to hash_hkdf().

Parameters

subkey_length

Length of the key to return (in bytes)

subkey_id

Return the Nth subkey from a given root key. Useful for seeking.

context

Application-specific context.

key

The root key from which the subkey is derived.

Return Values

A string of pseudorandom (raw binary) bytes.


<sodium_crypto_generichash_updatesodium_crypto_kdf_keygen>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026