Skip to content

Instantly share code, notes, and snippets.

@ghecho
Created January 29, 2015 06:20
Show Gist options
  • Save ghecho/2c4d2898e0253abeb592 to your computer and use it in GitHub Desktop.
Save ghecho/2c4d2898e0253abeb592 to your computer and use it in GitHub Desktop.
PHP BCrypt
<?PHP
echo better_crypt("password");
if(password_verify("password", better_crypt("password"))) {
// password is correct
echo "<br><br>";
echo "password correct";
}
function better_crypt($input, $rounds = 8)
{
// Original PHP code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.
$crypt_options = array(
'cost' => $rounds
);
return password_hash($input, PASSWORD_BCRYPT, $crypt_options);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment