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

ParagonIE_Sodium_File::secretbox_open() public WP 1.0

Seal a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_secretbox_open(), but produces the same result.

Warning: Does not protect against TOCTOU attacks. You should just load the file into memory and use crypto_secretbox_open() if you are worried about those.

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

Хуков нет.

Возвращает

true/false.

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

$result = ParagonIE_Sodium_File::secretbox_open( $inputFile, $outputFile, $nonce, $key );
$inputFile(строка) (обязательный)
$outputFile(строка) (обязательный)
$nonce(строка) (обязательный)
$key(строка) (обязательный)

Код ParagonIE_Sodium_File::secretbox_open() WP 5.5.1

<?php
public static function secretbox_open($inputFile, $outputFile, $nonce, $key)
{
    /* Type checks: */
    if (!is_string($inputFile)) {
        throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
    }
    if (!is_string($outputFile)) {
        throw new TypeError('Argument 2 must be a string, ' . gettype($outputFile) . ' given.');
    }
    if (!is_string($nonce)) {
        throw new TypeError('Argument 3 must be a string, ' . gettype($nonce) . ' given.');
    }
    if (!is_string($key)) {
        throw new TypeError('Argument 4 must be a string, ' . gettype($key) . ' given.');
    }

    /* Input validation: */
    if (self::strlen($nonce) !== ParagonIE_Sodium_Compat::CRYPTO_SECRETBOX_NONCEBYTES) {
        throw new TypeError('Argument 4 must be CRYPTO_SECRETBOX_NONCEBYTES bytes');
    }
    if (self::strlen($key) !== ParagonIE_Sodium_Compat::CRYPTO_SECRETBOX_KEYBYTES) {
        throw new TypeError('Argument 4 must be CRYPTO_SECRETBOXBOX_KEYBYTES bytes');
    }

    /** @var int $size */
    $size = filesize($inputFile);
    if (!is_int($size)) {
        throw new SodiumException('Could not obtain the file size');
    }

    /** @var resource $ifp */
    $ifp = fopen($inputFile, 'rb');
    if (!is_resource($ifp)) {
        throw new SodiumException('Could not open input file for reading');
    }

    /** @var resource $ofp */
    $ofp = fopen($outputFile, 'wb');
    if (!is_resource($ofp)) {
        fclose($ifp);
        throw new SodiumException('Could not open output file for writing');
    }

    $res = self::secretbox_decrypt($ifp, $ofp, $size, $nonce, $key);
    fclose($ifp);
    fclose($ofp);
    try {
        ParagonIE_Sodium_Compat::memzero($key);
    } catch (SodiumException $ex) {
        unset($key);
    }
    return $res;
}