0

I'm still using md5 hashing for my site and I need to upgrade, yet I don't know how... Here is the code that I'm using now

   $salt1 = "mysite";

   $salt1 = md5($salt1);

   $salt2 = "passed";

   $salt2 = md5($salt2);

   $salt3 = "php";

   $salt3 = md5($salt3);

   $password1 = $salt1.$password1.$salt3;
Ivan Nevostruev
  • 28,143
  • 8
  • 66
  • 82
Ayoub
  • 1
  • to what people nowadays use... – Ayoub Apr 16 '14 at 01:23
  • that narrows it down, people use everything and nothing –  Apr 16 '14 at 01:25
  • Also see Openwall's [PHP password hashing framework](http://www.openwall.com/phpass/) (PHPass). Its portable and hardened against a number of common attacks on user passwords. The guy who wrote the framework (SolarDesigner) is the same guy who wrote [John The Ripper](http://www.openwall.com/john/) and sits as a judge in the [Password Hashing Competition](http://password-hashing.net/). So he knows a thing or two about attacks on passwords. – jww Oct 12 '14 at 01:59

2 Answers2

3

Hopefully you're upgrading to bcrypt, which is now the standard. (PHP 5 >= 5.5.0)

The easiest way to do this is to store passwords in two columns. When someone connects and they don't have a bcrypt hashed password, take the valid password they entered, hash it with bcrypt, and store it in the new column. That user is now converted and you can blank out their old MD5ed one.

After a few months, disable any users who haven't used the site in that long and make them do a password reset to get access back. This allows for a gradual transition with minimal user impact.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
ceejayoz
  • 176,543
  • 40
  • 303
  • 368
1
<?php
/**
 * In this case, we want to increase the default cost for BCRYPT to 12.
 * Note that we also switched to BCRYPT, which will always be 60 characters.
 */
$options = [
    'cost' => 12,
];
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options)."\n";
?>

This is from the php manual, it would be the direction you need to go in. I would suggest further reading of the bcrypt feature built into PHP to gain a more insightful understanding.

Skewled
  • 783
  • 4
  • 12