Created
September 27, 2017 19:04
-
-
Save katalystsol/3bee4010300d94daaacfab87c0023b79 to your computer and use it in GitHub Desktop.
Update the old MD5 hash to the new bcrypt - one approach
This file contains 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
/* Update the old MD5 hash to the new bcrypt -- rough outline */ | |
if (strlen($member['password']) === 32) { | |
if ($member['password'] == md5( $_POST['password'] )){ | |
$password = password_hash( $_POST['password'], PASSWORD_BCRYPT ); | |
$DB->query("UPDATE members SET password='{$password}' WHERE id='{$member['id']}';"); | |
$auth_success = true; | |
} | |
} else { | |
/* Not 32 characters? Then it is a bcrypt password */ | |
if (password_verify($_POST['password'], $member['password'])) { | |
$auth_success = true; | |
$password = $member['password']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment