ParagonIE_Sodium_Crypto32::generichash_init

Advertisement

Summery Summery

Initialize a hashing context for BLAKE2b.

Syntax Syntax

ParagonIE_Sodium_Crypto32::generichash_init( string $key = '', int $outputLength = 32 )

Parameters Parameters

$key

(string) (Optional)

Default value: ''

$outputLength

(int) (Optional)

Default value: 32

Return Return

(string)

Source Source

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

    public static function generichash_init($key = '', $outputLength = 32)
    {
        // This ensures that ParagonIE_Sodium_Core32_BLAKE2b::$iv is initialized
        ParagonIE_Sodium_Core32_BLAKE2b::pseudoConstructor();

        $k = null;
        if (!empty($key)) {
            $k = ParagonIE_Sodium_Core32_BLAKE2b::stringToSplFixedArray($key);
            if ($k->count() > ParagonIE_Sodium_Core32_BLAKE2b::KEYBYTES) {
                throw new RangeException('Invalid key size');
            }
        }

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

        return ParagonIE_Sodium_Core32_BLAKE2b::contextToString($ctx);
    }

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.