public static function ParagonIE_Sodium_Compat::crypto_generichash_final in Automatic Updates 8
Same name and namespace in other branches
- 7 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::crypto_generichash_final()
Get the final BLAKE2b hash output for a given context.
@psalm-suppress MixedArgument @psalm-suppress ReferenceConstraintViolation @psalm-suppress ConflictingReferenceConstraint
Parameters
string $ctx BLAKE2 hashing context. Generated by crypto_generichash_init().:
int $length Hash output size.:
Return value
string Final BLAKE2b hash.
Throws
SodiumException
TypeError
6 calls to ParagonIE_Sodium_Compat::crypto_generichash_final()
- ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key in vendor/
paragonie/ sodium_compat/ src/ Compat.php - ParagonIE_Sodium_Compat::crypto_kx_client_session_keys in vendor/
paragonie/ sodium_compat/ src/ Compat.php - ParagonIE_Sodium_Compat::crypto_kx_server_session_keys in vendor/
paragonie/ sodium_compat/ src/ Compat.php - ParagonIE_Sodium_File::generichash in vendor/
paragonie/ sodium_compat/ src/ File.php - Calculate the BLAKE2b hash of a file.
- php72compat.php in vendor/
paragonie/ sodium_compat/ lib/ php72compat.php
File
- vendor/
paragonie/ sodium_compat/ src/ Compat.php, line 1440
Class
Code
public static function crypto_generichash_final(&$ctx, $length = self::CRYPTO_GENERICHASH_BYTES) {
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2);
if (self::useNewSodiumAPI()) {
return sodium_crypto_generichash_final($ctx, $length);
}
if (self::use_fallback('crypto_generichash_final')) {
$func = '\\Sodium\\crypto_generichash_final';
return (string) $func($ctx, $length);
}
if ($length < 1) {
try {
self::memzero($ctx);
} catch (SodiumException $ex) {
unset($ctx);
}
return '';
}
if (PHP_INT_SIZE === 4) {
$result = ParagonIE_Sodium_Crypto32::generichash_final($ctx, $length);
}
else {
$result = ParagonIE_Sodium_Crypto::generichash_final($ctx, $length);
}
try {
self::memzero($ctx);
} catch (SodiumException $ex) {
unset($ctx);
}
return $result;
}