ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_encrypt

Advertisement

Summery Summery

AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)

Syntax Syntax

ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_encrypt( string $message = '', string $ad = '', string $nonce = '', string $key = '' )

Parameters Parameters

$message

(Optional)

Default value: ''

$ad

(Optional)

Default value: ''

$nonce

(Optional)

Default value: ''

$key

(Optional)

Default value: ''

Return Return

(string)

Source Source

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

    public static function aead_xchacha20poly1305_ietf_encrypt(
        $message = '',
        $ad = '',
        $nonce = '',
        $key = ''
    ) {
        $subkey = ParagonIE_Sodium_Core32_HChaCha20::hChaCha20(
            ParagonIE_Sodium_Core32_Util::substr($nonce, 0, 16),
            $key
        );
        $nonceLast = "\x00\x00\x00\x00" .
            ParagonIE_Sodium_Core32_Util::substr($nonce, 16, 8);

        return self::aead_chacha20poly1305_ietf_encrypt($message, $ad, $nonceLast, $subkey);
    }

Advertisement

Advertisement

Leave a Reply