WordPress at Your Fingertips
function is not described

ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash() public WP 1.0

Do we need to rehash this password?

{} It's a method of the class: ParagonIE_Sodium_Compat{}

No Hooks.

Return

true|false.

Usage

$result = ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash( $hash, $opslimit, $memlimit );
$hash(string) (required)
-
$opslimit(int) (required)
-
$memlimit(int) (required)
-

Code of ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash() WP 5.8.2

public static function crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit)
{
    ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 1);
    ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
    ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);

    // Just grab the first 4 pieces.
    $pieces = explode('$', (string) $hash);
    $prefix = implode('$', array_slice($pieces, 0, 4));

    // Rebuild the expected header.
    /** @var int $ops */
    $ops = (int) $opslimit;
    /** @var int $mem */
    $mem = (int) $memlimit >> 10;
    $encoded = self::CRYPTO_PWHASH_STRPREFIX . 'v=19$m=' . $mem . ',t=' . $ops . ',p=1';

    // Do they match? If so, we don't need to rehash, so return false.
    return !ParagonIE_Sodium_Core_Util::hashEquals($encoded, $prefix);
}