CKTIS / PHP
password_needs_rehash()
Confronta algoritmo e costo dell’hash memorizzato con le impostazioni richieste.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
password_needs_rehash(string $hash, string|int|null $algo, array $options = []): boolConfronta algoritmo e costo dell’hash memorizzato con le impostazioni richieste. Una differenza restituisce true senza verificare la password. Dopo una verifica riuscita, generare e salvare il nuovo hash dalla password fornita.
Firma
password_needs_rehash(string $hash, string|int|null $algo, array $options = []): bool
Output dell’esempio
[false,true]
Esempi
<?php
$stored=password_hash("maple notes",PASSWORD_BCRYPT,["cost"=>12]);
echo json_encode([password_needs_rehash($stored,PASSWORD_BCRYPT,["cost"=>12]),password_needs_rehash($stored,PASSWORD_BCRYPT,["cost"=>13])]);
Risultato
[false,true]