Created
January 16, 2017 18:37
-
-
Save thiagoeliasr/47fec01ec7b367a88e116004a27da7fe to your computer and use it in GitHub Desktop.
Tools class, to generate Laravel-Format Hash, including Salt and Cost.
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
<?php | |
class Tools { | |
public static function generateLaravelHash($cost, $salt, $pass) | |
{ | |
return password_hash($pass, PASSWORD_BCRYPT, [ | |
'cost' => $cost, | |
'salt' => $salt | |
]); | |
} | |
public static function checkLaravelHash($pass, $hash) | |
{ | |
return (crypt($pass, $hash) === $hash); | |
} | |
} | |
//testing | |
echo Tools::generateLaravelHash(10, 'VQUUdxdHwwDl6LSGm1jbeNN', '123456'); | |
if (Tools::checkLaravelHash('123456', '$2y$10$VQUUdxdHwwDl6LSGm1jbe.SeY3UirFCld2tlOM.ms1DhdeAPb/lr6')) { | |
echo "True"; | |
} else { | |
echo "False"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment