ParagonIE_Sodium_Crypto::generichash_init_salt_personal

Advertisement

Summery Summery

Initialize a hashing context for BLAKE2b.

Syntax Syntax

ParagonIE_Sodium_Crypto::generichash_init_salt_personal( string $key = '', int $outputLength = 32, string $salt = '', string $personal = '' )

Parameters Parameters

$key

(Optional)

Default value: ''

$outputLength

(Optional)

Default value: 32

$salt

(Optional)

Default value: ''

$personal

(Optional)

Default value: ''

Return Return

(string)

Source Source

File: wp-includes/sodium_compat/src/Crypto.php

    public static function generichash_init_salt_personal(
        $key = '',
        $outputLength = 32,
        $salt = '',
        $personal = ''
    ) {
        // This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
        ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();

        $k = null;
        if (!empty($key)) {
            $k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
            if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
                throw new RangeException('Invalid key size');
            }
        }
        if (!empty($salt)) {
            $s = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($salt);
        } else {
            $s = null;
        }
        if (!empty($salt)) {
            $p = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($personal);
        } else {
            $p = null;
        }

        /** @var SplFixedArray $ctx */
        $ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outputLength, $s, $p);

        return ParagonIE_Sodium_Core_BLAKE2b::contextToString($ctx);
    }

Advertisement

Advertisement

Leave a Reply