<?php
$password = 'rasmuslerdorf';
$hash = '$2y$10$YCFsG6elYca568hBi2pZ0.3LDL5wjgxct1N8w/oLR/jfHsiQwCqTS';
// El parámetro cost puede cambiar con el tiempo al mejorar el hardware
$options = array('cost' => 11);
// Verificar el hash almacenado con la contraseña en texto plano
if (password_verify($password, $hash)) {
// Comprobar hay un nuevo algoritmo de hash
// o ha cambiado el coste
if (password_needs_rehash($hash, PASSWORD_DEFAULT, $options)) {
// Si es así, crear un nuevo hash y reemplazar el antiguo
$newHash = password_hash($password, PASSWORD_DEFAULT, $options);
}
// Identificar al usuario
}
?>