Skip to content

Instantly share code, notes, and snippets.

@dshafik
Created February 11, 2012 23:11
Show Gist options
  • Save dshafik/1804939 to your computer and use it in GitHub Desktop.
Save dshafik/1804939 to your computer and use it in GitHub Desktop.
<?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