You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
481 B

<?php
echo "Enter a password: ";
hide_term();
$password1 = trim(fgets(STDIN), PHP_EOL);
echo PHP_EOL;
echo "Confirm password: ";
$password2 = trim(fgets(STDIN), PHP_EOL);
echo PHP_EOL;
restore_term();
if($password1 == $password2) {
$hash = password_hash($password1, PASSWORD_DEFAULT);
echo "Password hash: $hash\n";
} else {
echo "Passwords did not match\n";
die(1);
}
function hide_term() {
system('stty -echo');
}
function restore_term() {
system('stty echo');
}