Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Created August 23, 2012 17:35
Show Gist options
  • Save TiuTalk/3439186 to your computer and use it in GitHub Desktop.
Save TiuTalk/3439186 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