array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.sodium-crypto-generichash.php', 1 => 'sodium_crypto_generichash', 2 => 'Get a hash of the message', ), 'up' => array ( 0 => 'ref.sodium.php', 1 => 'Sodium 函数', ), 'prev' => array ( 0 => 'function.sodium-crypto-core-ristretto255-sub.php', 1 => 'sodium_crypto_core_ristretto255_sub', ), 'next' => array ( 0 => 'function.sodium-crypto-generichash-final.php', 1 => 'sodium_crypto_generichash_final', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/sodium/functions/sodium-crypto-generichash.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

sodium_crypto_generichash

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_generichashGet a hash of the message

说明

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

Hash a message with BLAKE2b.

参数

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.

返回值

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