So I have the password check for an old website defined as:
if($i['password'] == hash('PASSWORD_BCRYPT',$p.$i['salt']) || sha1($p) == $i['password']) {
and it uses the following to select data from the database.
$u = $mysqli->real_escape_string($_REQUEST['username']);
$p = $_REQUEST['password'];
$s = $mysqli->query("SELECT * FROM `accounts` WHERE `name`='".$u."'") or die();
$i = $s->fetch_assoc();
I understand Sha1 was never meant to be used for password encryption, rather in order to obtain a faster processing speed, so I want to migrate over to BCrypt. Despite countless attempts, I can't seem to get it to work. (sorry still learning php) This is what I got so far:
$options = [ 'cost' => 12];
if($i['password'] == password_hash($p.$i['salt'], PASSWORD_BCRYPT, $options) || password_hash($p, PASSWORD_BCRYPT, $options) == $i['password']){
My login script doesn't allow the login to proceed so the passwords defined, given and retrieved, aren't matching. I know bcrypt is stored properly as my java application, defined by BCrypt.hashpw(pass, BCrypt.gensalt(12)); can read and write properly. So why can't the website?