WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() public WP 1.0

Authenticated Encryption with Associated Data: Decryption

Algorithm:

ChaCha20-Poly1305

IETF mode uses a 96-bit random nonce with a 32-bit counter. Regular mode uses a 64-bit random nonce with a 64-bit counter.

{} Это метод класса: ParagonIE_Sodium_Compat{}

Хуков нет.

Возвращает

Строку. The original plaintext message

Использование

$result = ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt(;
$ciphertext(строка) (обязательный)
Encrypted message (with Poly1305 MAC appended)
$assocData(строка) (обязательный)
Authenticated Associated Data (unencrypted)
$nonce(строка) (обязательный)
Number to be used only Once; must be 12 bytes
$key(строка) (обязательный)
Encryption key

Код ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() WP 5.5.1

<?php
public static function crypto_aead_chacha20poly1305_ietf_decrypt(
    $ciphertext = '',
    $assocData = '',
    $nonce = '',
    $key = ''
) {
    /* Type checks: */
    ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
    ParagonIE_Sodium_Core_Util::declareScalarType($assocData, 'string', 2);
    ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 3);
    ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4);

    /* Input validation: */
    if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES) {
        throw new SodiumException('Nonce must be CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES long');
    }
    if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES) {
        throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
    }
    if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_CHACHA20POLY1305_ABYTES) {
        throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
    }

    if (self::useNewSodiumAPI()) {
        /**
         * @psalm-suppress InvalidReturnStatement
         * @psalm-suppress FalsableReturnStatement
         */
        return sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
            $ciphertext,
            $assocData,
            $nonce,
            $key
        );
    }
    if (self::use_fallback('crypto_aead_chacha20poly1305_ietf_decrypt')) {
        return call_user_func(
            '\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt',
            $ciphertext,
            $assocData,
            $nonce,
            $key
        );
    }
    if (PHP_INT_SIZE === 4) {
        return ParagonIE_Sodium_Crypto32::aead_chacha20poly1305_ietf_decrypt(
            $ciphertext,
            $assocData,
            $nonce,
            $key
        );
    }
    return ParagonIE_Sodium_Crypto::aead_chacha20poly1305_ietf_decrypt(
        $ciphertext,
        $assocData,
        $nonce,
        $key
    );
}