Advertisement
bu2chlc

Password hashing

Oct 30th, 2019
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2. // correct password
  3. $password = "PlainTextPassword";
  4. echo "The password is: " . $password . "<br>";
  5.  
  6. // hash the password and assign to variable "$HashedPassword"
  7. $HashedPassword=password_hash($password, PASSWORD_DEFAULT);
  8. echo "The HASHED password is: " . $HashedPassword . "<br><br>";
  9.  
  10. // compare "$password" to "$HashedPassword"
  11. echo "comparing password to hashed password: ". "<br>";
  12. if (password_verify('PlainTextPassword', $HashedPassword)) {
  13.     echo "Password matches!" . "<br>";
  14. } else {
  15.     echo "Invalid password". "<br>";
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement