Skip to content

Instantly share code, notes, and snippets.

@katalystsol
Created September 27, 2017 19:04
Show Gist options
  • Save katalystsol/3bee4010300d94daaacfab87c0023b79 to your computer and use it in GitHub Desktop.
Save katalystsol/3bee4010300d94daaacfab87c0023b79 to your computer and use it in GitHub Desktop.
Update the old MD5 hash to the new bcrypt - one approach
/* 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