PHP.nl

password_verify

password_verify

Verifies that a password matches a hash

bool **password_verify** string $password string $hash

Verifies that the given hash matches the given password. is compatible with . Therefore, password hashes created by can be used with . password_verify``crypt``crypt``password_verify

Note that returns the algorithm, cost and salt as part of the returned hash. Therefore, all information that's needed to verify the hash is included in it. This allows the verify function to verify the hash without needing separate storage for the salt or algorithm information. password_hash

This function is safe against timing attacks.

passwordpassword.parameter.password

hashpassword.parameter.hash

Returns true if the password and hash match, or false otherwise.

Voorbeeld: example

 This is a simplified example; it is recommended to rehash a correct password
 if necessary; see  for an example.
`password_needs_rehash`
<?php
// See the password_hash() example to see where this came from.
$hash = '$2y$12$4Umg0rCJwMswRw/l.SwHvuQV01coP0eWmGzd61QH2RvAOMANUBGC.';

if (password_verify('rasmuslerdorf', $hash)) {
    echo 'Password is valid!';
} else {
    echo 'Invalid password.';
}
?>
Password is valid!

password_needs_rehash``password_hash``sodium_crypto_pwhash_str_verify