ParagonIE_Sodium_Compat::crypto_pwhash

Advertisement

Syntax Syntax

ParagonIE_Sodium_Compat::crypto_pwhash( int $outlen, string $passwd, string $salt, int $opslimit, int $memlimit, int|null $alg = null )

Parameters Parameters

$outlen

(Required)

$passwd

(Required)

$salt

(Required)

$opslimit

(Required)

$memlimit

(Required)

$alg

(Optional)

Default value: null

Return Return

(string)

Source Source

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

    public static function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg = null)
    {
        ParagonIE_Sodium_Core_Util::declareScalarType($outlen, 'int', 1);
        ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 2);
        ParagonIE_Sodium_Core_Util::declareScalarType($salt,  'string', 3);
        ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
        ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);

        if (self::useNewSodiumAPI()) {
            if (!is_null($alg)) {
                ParagonIE_Sodium_Core_Util::declareScalarType($alg, 'int', 6);
                return sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg);
            }
            return sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit);
        }
        if (self::use_fallback('crypto_pwhash')) {
            return (string) call_user_func('\\Sodium\\crypto_pwhash', $outlen, $passwd, $salt, $opslimit, $memlimit);
        }
        // This is the best we can do.
        throw new SodiumException(
            'This is not implemented, as it is not possible to implement Argon2i with acceptable performance in pure-PHP'
        );
    }

Advertisement

Advertisement

Leave a Reply