Created
October 5, 2019 07:32
-
-
Save caironm/ca10d4546a0d4de0b29eac3f0c21d2e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$password = 'rasmuslerdorf'; | |
$hash = '$2y$10$YCFsG6elYca568hBi2pZ0.3LDL5wjgxct1N8w/oLR/jfHsiQwCqTS'; | |
// O parâmetro cost pode mudar com o tempo, à medida que o hardware melhora | |
$options = array('cost' => 11); | |
// Verificar hash armazenado contra senha de texto sem formatação | |
if (password_verify($password, $hash)) { | |
// Verifique se um algoritmo de hash mais recente está disponível | |
// ou o custo mudou | |
if (password_needs_rehash($hash, PASSWORD_DEFAULT, $options)) { | |
// Nesse caso, crie um novo hash e substitua o antigo | |
$newHash = password_hash($password, PASSWORD_DEFAULT, $options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment