Howdy,
Even though this example works without using hash() or sha256 but by using password_hash() where salt is built-in:
**SAMPLE 1
[code]
$password = ‘password’;
echo $hashed_password = password_hash($password,PASSWORD_DEFAULT); //60 line hashed characters.
if(password_verify($password,$hashed_password))
{
echo ‘Logging in’;
}
else
{
echo ‘Incorrect Details!’;
}
I cannot seem to get it to work with sha256 AND hash().
Both these following 2 are failing to authenticate properly. Why ?
**NOTE
Remember, the above was using password_hash() and the two below are trying to use just hash(), where salt is not built-in
**SAMPLE 2
[code]
$password = ‘password’;
$salt = ’12’;
$salted_hashed_password = hash(‘sha256′,$password.’12’);
$secured_password = password_hash($salted_hashed_password,PASSWORD_DEFAULT);
if(password_verify($password,$secured_password))
{
echo ‘Logging in’;
}
else
{
echo ‘Incorrect Details!’;
}
How to fix it as I get echoed …?
**‘Incorrect Details!’
**SAMPLE 3
[code]
$password = ‘password’;
$salt = ’12’;
$salted_password = $password.’12’;
$hashed_salted_password = hash(‘sha256’,$salted_password);
$secured_password = password_hash($hashed_salted_password,PASSWORD_DEFAULT);
if(password_verify($password,$secured_password))
{
echo ‘Logging in’;
}
else
{
echo ‘Incorrect Details!’;
}
How to fix it as I get echoed here too …?
**‘Incorrect Details!’