We are migratin from PHP 5.6 / CodeIgniter 3 to PHP 8.3.4 / CodeIginier 4. In the old version we used the below method on user registration and saved $salt
and $password
in the db.
$salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), TRUE));
$password = hash('sha512', $data['password'] . $salt);
When user login we have used the below method
$results = $query->getRowArray();
$salted_password = hash('sha512', $password . $results['salt']);
if ($results['password'] == $salted_password) { return true; }
The new version is giving password mismatch with the existing users credentials in the DB. But it works totally fine with the new registered user.
Any idea about why is this happening? Any suggestion to make it work with the existing users credentials?