Last active
May 12, 2018 02:31
-
-
Save drmcarvalho/a7cd603e516b3ad5a109854e6e821cad to your computer and use it in GitHub Desktop.
Exemplo de Hash usando a função password_hash().
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 | |
/* | |
* Autor: Dener Carvalho, Marks, Vinicius | |
* | |
* Implementação da função password_hash: https://github.com/php/php-src/blob/master/ext/standard/password.c#L412 | |
* | |
* | |
* Implementação da função password_verify: https://github.com/php/php-src/blob/master/ext/standard/password.c#L291 | |
* | |
* Documentação password_verify: http://php.net/manual/pt_BR/function.password-verify.php | |
* | |
* Documentação password_hash: http://php.net/manual/pt_BR/function.password-hash.php | |
*/ | |
$senha = "minhaSenha"; | |
$hash = password_hash($senha, PASSWORD_DEFAULT); | |
echo "Valor (senha): " . $senha . "\n\n"; | |
echo "Novo valor (hash): " . $hash . "\n\n"; | |
if (password_verify('minhaSenha', $hash)) | |
echo "Senha válida.\n"; | |
else | |
echo "Senha inválida.\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment