Created
November 15, 2015 02:22
-
-
Save RicardoACS/6b92ae7b151afc198bbc to your computer and use it in GitHub Desktop.
Encriptar Password en PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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