Skip to content

Instantly share code, notes, and snippets.

@robertopc
Forked from TiuTalk/gist:3439186
Last active October 14, 2015 19:54
Show Gist options
  • Save robertopc/0369b0108ef4bc880f77 to your computer and use it in GitHub Desktop.
Save robertopc/0369b0108ef4bc880f77 to your computer and use it in GitHub Desktop.
<?php
// Encriptando a senha
$senha = 'ola mundo';
$hash = Bcrypt::hash($senha);
// $hash = $2a$08$MTgxNjQxOTEzMTUwMzY2OOc15r9yENLiaQqel/8A82XLdj.OwIHQm
// Salve $hash no banco de dados
// Verificando a senha
$senha = 'ola mundo';
$hash = '$2a$08$MTgxNjQxOTEzMTUwMzY2OOc15r9yENLiaQqel/8A82XLdj.OwIHQm'; // Valor retirado do banco
if (Bcrypt::check($senha, $hash)) {
echo 'Senha OK!';
} else {
echo 'Senha incorreta!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment