Skip to content

Instantly share code, notes, and snippets.

@everaldo
Created May 28, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everaldo/9387b04efb46196376c7 to your computer and use it in GitHub Desktop.
Save everaldo/9387b04efb46196376c7 to your computer and use it in GitHub Desktop.
Senhas com password verify (a partir do PHP 5.5.0 - 20 de Junho de 2013)
<?php
$senha = 'Of!cinaDePr0gramaçã0';
$hash = password_hash($senha, PASSWORD_DEFAULT);
$salt = substr($hash, 7, 22);
$verificacao = password_verify($senha, $hash) ? "Verdadeiro" : "Falso";
$teste_falso = password_verify("N@oEhaSenha", $hash) ? "Verdadeiro" : "Falso";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Senhas com Password Hash (a partir do PHP 5.5.0)</title>
</head>
<body>
<h1>Senhas com a função password_hash()</h1>
<p>
<b>Senha:</b> <?php echo $senha ?></br>
<b>Hash:</b> <?php echo $hash ?></br>
<b>Salt:</b> <?php echo $salt ?></br>
<b>Verificação:</b> <?php echo $verificacao ?></br>
<b>Teste Senha Incorreta:</b> <?php echo $teste_falso ?></br>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment