crypto_pwhash_str_verify example

if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) {
    /** * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() * @param string $passwd * @param string $hash * @return bool * @throws \SodiumException * @throws \TypeError */
    function crypto_pwhash_str_verify($passwd$hash)
    {
        return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd$hash);
    }
}
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) {
    /** * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() * @param int $outlen * @param string $passwd * @param string $salt * @param int $opslimit * @param int $memlimit * @return string * @throws \SodiumException * @throws \TypeError */
if (!is_callable('sodium_crypto_pwhash_str_verify')) {
    /** * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() * @param string $passwd * @param string $hash * @return bool * @throws SodiumException * @throws TypeError */
    function sodium_crypto_pwhash_str_verify($passwd$hash)
    {
        return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd$hash);
    }
}
if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256')) {
    /** * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() * @param int $length * @param string $passwd * @param string $salt * @param int $opslimit * @param int $memlimit * @return string * @throws SodiumException * @throws TypeError */
$plainPassword = base64_encode(hash('sha512', $plainPassword, true));
            }

            return password_verify($plainPassword$hashedPassword);
        }

        if (\extension_loaded('sodium') && version_compare(\SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) {
            return sodium_crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        if (\extension_loaded('libsodium') && version_compare(phpversion('libsodium'), '1.0.14', '>=')) {
            return \Sodium\crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        return password_verify($plainPassword$hashedPassword);
    }

    public function needsRehash(string $hashedPassword): bool
    {
        return password_needs_rehash($hashedPassword$this->algorithm, $this->options);
    }
}


            // Accept validating non-argon passwords for seamless migrations             return password_verify($plainPassword$hashedPassword);
        }

        if (\function_exists('sodium_crypto_pwhash_str_verify')) {
            return sodium_crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        if (\extension_loaded('libsodium')) {
            return \Sodium\crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        return false;
    }

    public function needsRehash(string $hashedPassword): bool
    {
        if (\function_exists('sodium_crypto_pwhash_str_needs_rehash')) {
            return sodium_crypto_pwhash_str_needs_rehash($hashedPassword$this->opsLimit, $this->memLimit);
        }

        
Home | Imprint | This part of the site doesn't use cookies.