ParagonIE_Sodium_Compat::memzero

Advertisement

Summery Summery

It’s actually not possible to zero memory buffers in PHP. You need the native library for that.

Syntax Syntax

ParagonIE_Sodium_Compat::memzero( string|null $var )

Parameters Parameters

$var

(string|null) (Required)

Return Return

(void)

Source Source

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

    public static function memzero(&$var)
    {
        /* Type checks: */
        ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);

        if (self::useNewSodiumAPI()) {
            /** @psalm-suppress MixedArgument */
            sodium_memzero($var);
            return;
        }
        if (self::use_fallback('memzero')) {
            $func = '\\Sodium\\memzero';
            $func($var);
            if ($var === null) {
                return;
            }
        }
        // This is the best we can do.
        throw new SodiumException(
            'This is not implemented in sodium_compat, as it is not possible to securely wipe memory from PHP. ' .
            'To fix this error, make sure libsodium is installed and the PHP extension is enabled.'
        );
    }

Advertisement

Advertisement

Leave a Reply

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