Summery Summery
Initialize a BLAKE2b hashing context, for use in a streaming interface.
Syntax Syntax
Parameters Parameters
- $key
-
(Optional) If specified must be a string between 16 and 64 bytes
Default value: ''
- $length
-
(Optional) The size of the desired hash output
Default value: self::CRYPTO_GENERICHASH_BYTES
- $salt
-
(Optional) Salt (up to 16 bytes)
Default value: ''
- $personal
-
(Optional) Personalization string (up to 16 bytes)
Default value: ''
Return Return
(string) A BLAKE2 hashing context, encoded as a string (To be 100% compatible with ext/libsodium)
Source Source
File: wp-includes/sodium_compat/src/Compat.php
public static function crypto_generichash_init_salt_personal( $key = '', $length = self::CRYPTO_GENERICHASH_BYTES, $salt = '', $personal = '' ) { /* Type checks: */ if (is_null($key)) { $key = ''; } ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 1); ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2); ParagonIE_Sodium_Core_Util::declareScalarType($salt, 'string', 3); ParagonIE_Sodium_Core_Util::declareScalarType($personal, 'string', 4); $salt = str_pad($salt, 16, "\0", STR_PAD_RIGHT); $personal = str_pad($personal, 16, "\0", STR_PAD_RIGHT); /* Input validation: */ if (!empty($key)) { /* if (ParagonIE_Sodium_Core_Util::strlen($key) < self::CRYPTO_GENERICHASH_KEYBYTES_MIN) { throw new SodiumException('Unsupported key size. Must be at least CRYPTO_GENERICHASH_KEYBYTES_MIN bytes long.'); } */ if (ParagonIE_Sodium_Core_Util::strlen($key) > self::CRYPTO_GENERICHASH_KEYBYTES_MAX) { throw new SodiumException('Unsupported key size. Must be at most CRYPTO_GENERICHASH_KEYBYTES_MAX bytes long.'); } } if (PHP_INT_SIZE === 4) { return ParagonIE_Sodium_Crypto32::generichash_init_salt_personal($key, $length, $salt, $personal); } return ParagonIE_Sodium_Crypto::generichash_init_salt_personal($key, $length, $salt, $personal); }