Bubelbub

Bukkit AuthMe Password Encryption Check Function

Oct 25th, 2012
2,870
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2. // Test with password 'test'
  3.  
  4. $password = 'test'; // this is the password of the user - example $_POST['password'] etc.
  5. $databasePassword = '$SHA$cef5c493b31eb182$00f1bef9906b0c406bf1040412c8bfa95f672a3e4117d49a4ff3e245d4d4d981'; // this is the password which is saved in the database
  6.  
  7. /**
  8.  * Checks the AuthMe password (Custom SHA256)
  9.  */
  10. function checkPassword($password, $databasePassword)
  11. {
  12.     $tmp = explode('$', $databasePassword);
  13.     $same = false;
  14.     if(hash('sha256', hash('sha256', $password) . $tmp[2]) == $tmp[3])
  15.     {
  16.         $same = true;
  17.     }
  18.     return $same;
  19. }
  20.  
  21. // The result...
  22. echo checkPassword($password, $databasePassword) ? 'The password is correct!' : 'The password is incorrect!';
  23. // It should echo
Advertisement
Add Comment
Please, Sign In to add comment