<?php
$password = 'rasmuslerdorf';
$hash = '$2y$12$4Umg0rCJwMswRw/l.SwHvuQV01coP0eWmGzd61QH2RvAOMANUBGC.';
$algorithm = PASSWORD_BCRYPT;
// bcrypt's cost parameter can change over time as hardware improves
$options = ['cost' => 13];
// Verify stored hash against plain-text password
if (password_verify($password, $hash)) {
// Check if either the algorithm or the options have changed
if (password_needs_rehash($hash, $algorithm, $options)) {
// If so, create a new hash, and replace the old one
$newHash = password_hash($password, $algorithm, $options);
// Update the user record with the $newHash
}
// Perform the login.
}
?>