Skip to content

Instantly share code, notes, and snippets.

@RicardoACS
Created November 15, 2015 02:22
Show Gist options
  • Save RicardoACS/6b92ae7b151afc198bbc to your computer and use it in GitHub Desktop.
Save RicardoACS/6b92ae7b151afc198bbc to your computer and use it in GitHub Desktop.
Encriptar Password en PHP
//Funcion
function crypt_blowfish_bydinvaders($password, $digito = 7)
{
$set_salt = './1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$salt = sprintf('$2a$%02d$', $digito);
for($i = 0; $i < 22; $i++)
{
$salt .= $set_salt[mt_rand(0, 22)];
}
return crypt($password, $salt);
}
//Encriptar
->crypt_blowfish_bydinvaders($passwordDefinitiva)
//Comprobar con la DB
if(crypt("passwordEntregadaPorLaPágina", "PasswordEntregadaPorLaBD") == "PasswordEntregadaPorLaBD")
{
$esIgual = TRUE;
}
else
{
$esIgual = FALSE;
}
// y después set la contraseña
->setPassword("passwordEntregadaPorLaPágina");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment