Created
September 7, 2020 06:18
-
-
Save cp-vrkansagara/f68801bb1788b0d2897f3c247aaff637 to your computer and use it in GitHub Desktop.
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 | |
$continue = "y"; | |
while (($continue == 'y' || $continue == 'Y') == true) { | |
echo 'Enter username :- '; | |
$usernme = trim(fread(STDIN, 40)); | |
echo 'Enter password :- '; | |
$password = trim(fread(STDIN, 40)); | |
$options = [ | |
'cost' => 12 // the default cost is 10 | |
]; | |
echo 'Please confirm password :- '; | |
$passwordAsk = trim(fread(STDIN, 40)); | |
$hash = password_hash($passwordAsk, PASSWORD_DEFAULT, $options); | |
if (password_needs_rehash($hash, PASSWORD_DEFAULT, $options)) { | |
// the password needs to be rehashed as it was not generated with | |
// the current default algorithm or not created with the cost | |
// parameter 12 | |
$hash = password_hash($passwordAsk, PASSWORD_DEFAULT, $options); | |
// don't forget to store the new hash! | |
} | |
if (password_verify($password, $hash)) { | |
echo 'Password match.'; | |
} else { | |
echo 'Invalid password.'; | |
} | |
echo 'Do you wanted to add more user(s) ? (Press Y or y for continue)'; | |
$continue = trim(fgetc(STDIN)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment