Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Test with password 'test'
- $password = 'test'; // this is the password of the user - example $_POST['password'] etc.
- $databasePassword = '$SHA$cef5c493b31eb182$00f1bef9906b0c406bf1040412c8bfa95f672a3e4117d49a4ff3e245d4d4d981'; // this is the password which is saved in the database
- /**
- * Checks the AuthMe password (Custom SHA256)
- */
- function checkPassword($password, $databasePassword)
- {
- $tmp = explode('$', $databasePassword);
- $same = false;
- if(hash('sha256', hash('sha256', $password) . $tmp[2]) == $tmp[3])
- {
- $same = true;
- }
- return $same;
- }
- // The result...
- echo checkPassword($password, $databasePassword) ? 'The password is correct!' : 'The password is incorrect!';
- // It should echo
Advertisement
Add Comment
Please, Sign In to add comment