ParagonIE_Sodium_Crypto32::generichash() public WP 1.0
Calculate a BLAKE2b hash.
{} Это метод класса: ParagonIE_Sodium_Crypto32{}
Хуков нет.
Возвращает
Строку
. Ничего.
Использование
$result = ParagonIE_Sodium_Crypto32::generichash( $message, $key, $outlen );
- $message(строка) (обязательный)
- -
- $key(строка/null)
- -
- $outlen(число)
- -
Код ParagonIE_Sodium_Crypto32::generichash() ParagonIE Sodium Crypto32::generichash WP 5.7.1
public static function generichash($message, $key = '', $outlen = 32)
{
// This ensures that ParagonIE_Sodium_Core32_BLAKE2b::$iv is initialized
ParagonIE_Sodium_Core32_BLAKE2b::pseudoConstructor();
$k = null;
if (!empty($key)) {
/** @var SplFixedArray $k */
$k = ParagonIE_Sodium_Core32_BLAKE2b::stringToSplFixedArray($key);
if ($k->count() > ParagonIE_Sodium_Core32_BLAKE2b::KEYBYTES) {
throw new RangeException('Invalid key size');
}
}
/** @var SplFixedArray $in */
$in = ParagonIE_Sodium_Core32_BLAKE2b::stringToSplFixedArray($message);
/** @var SplFixedArray $ctx */
$ctx = ParagonIE_Sodium_Core32_BLAKE2b::init($k, $outlen);
ParagonIE_Sodium_Core32_BLAKE2b::update($ctx, $in, $in->count());
/** @var SplFixedArray $out */
$out = new SplFixedArray($outlen);
$out = ParagonIE_Sodium_Core32_BLAKE2b::finish($ctx, $out);
/** @var array<int, int> */
$outArray = $out->toArray();
return ParagonIE_Sodium_Core32_Util::intArrayToString($outArray);
}