Syntax Syntax

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

Parameters Parameters


(int) (Required)


(string) (Required)


(string) (Required)


(int) (Required)


(int) (Required)


(int|null) (Optional)

Default value: null

Return Return


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'



Leave a Reply

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