I've used MD5()
password hashing in an old application and I want to switch to crypt()
hashing since its more secure. But... I don't have any experiance with the crypt()
function.
So now for hashing I have this:
function hashPassword($uPassword) {
$processingPower = 10;
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
$salt = sprintf("$2a$%02d$", $processingPower) . $salt;
$hash = crypt($password, $salt);
return $hash;
}
And to compare the password, I have this:
if (crypt($uPassword, $uData['uPassword']) == $uData['uPassword'])
All seems to work fine, but I can still login with the old (MD5) passwords stored in my dB. Is this normal behaviour or is there something wrong in my code?