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_core_ristretto255_subsodium_crypto_generichash_final>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026

sodium_crypto_generichash

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_generichash — Get a hash of the message

Description

function sodium_crypto_generichash(string $message, #[\SensitiveParameter] string $key = "", int $length = SODIUM_CRYPTO_GENERICHASH_BYTES): string

Hash a message with BLAKE2b.

Parameters

message

The message being hashed.

key

(Optional) cryptographic key. This serves the same function as a HMAC key, but it's utilized as a reserved section of the internal BLAKE2 state.

length

Output size.

Return Values

The cryptographic hash as raw bytes. If a hex-encoded output is desired, the result can be passed to sodium_bin2hex().


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