Created
February 11, 2012 23:11
-
-
Save dshafik/1804939 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$good_salt = '$2y$10$22randomcharactershere$'; | |
$logged_in = false; | |
if (strpos($stored_password, '$2a$') === 0) { | |
$bad_hash = '$2x$' .substr($stored_password, 4); | |
if (crypt($input_password, $bad_hash) == $bad_hash)) { | |
// generate a new password | |
$good_hash = crypt($input_password, $good_salt); | |
// Store $good_hash in-place of the original hash | |
} | |
$logged_in = true; | |
} elseif (crypt($input_password, $input_password) == $stored_password) { | |
$logged_in = true; | |
} else { | |
// Bad login | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment