24 lines
437 B

  1. <?php
  2. echo "Enter password hash to verify against: ";
  3. $hash = trim(fgets(STDIN), PHP_EOL);
  4. echo "Enter password: ";
  5. hide_term();
  6. $password = trim(fgets(STDIN), PHP_EOL);
  7. echo PHP_EOL;
  8. restore_term();
  9. $verified = password_verify($password, $hash);
  10. if($verified)
  11. echo "Password verified\n";
  12. else
  13. echo "Password did not match\n";
  14. function hide_term() {
  15. system('stty -echo');
  16. }
  17. function restore_term() {
  18. system('stty echo');
  19. }