PHP - password_hash gives me different results with same values

44 Views Asked by At

I'm making a register page for my website. I wanted to hash the password before send it to the database. Therefore, I used the password_hash() method. But this method gives different results with same password.

Here is my code;

    $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
    $hashedPassword2 = password_hash($password, PASSWORD_DEFAULT);

    echo $hashedPassword. "   ------    ".$hashedPassword2;
    

And the result; result

I've tried password_verify() method just to make sure. It also says 'false'.

$result =  password_verify($hashedPassword,$hashedPassword2);
echo var_export($result, true);

Here is the result; result-2

Normally, It wouldn't be a problem for me. But I am going to need the similar process in my login page. What should I do? Should I try a different hashing method?

0

There are 0 best solutions below