ParagonIE_Sodium_Core_XChaCha20::ietfStream

Advertisement

Syntax Syntax

ParagonIE_Sodium_Core_XChaCha20::ietfStream( int $len = 64, string $nonce = '', string $key = '' )

Parameters Parameters

$len

(Optional)

Default value: 64

$nonce

(Optional)

Default value: ''

$key

(Optional)

Default value: ''

Return Return

(string)

Source Source

File: wp-includes/sodium_compat/src/Core/XChaCha20.php

    public static function ietfStream($len = 64, $nonce = '', $key = '')
    {
        if (self::strlen($nonce) !== 24) {
            throw new SodiumException('Nonce must be 24 bytes long');
        }
        return self::encryptBytes(
            new ParagonIE_Sodium_Core_ChaCha20_IetfCtx(
                self::hChaCha20(
                    self::substr($nonce, 0, 16),
                    $key
                ),
                "\x00\x00\x00\x00" . self::substr($nonce, 16, 8)
            ),
            str_repeat("\x00", $len)
        );
    }

Advertisement

Advertisement

Leave a Reply