Password hash different results on same word

I am hashing my password with this method:
public static function make($string, $salt = ‘’) {
return hash(‘sha256’, $string . $salt);
}

I’m checking it with that one:
if($this->data()->password === Hash::make($password)) {
echo ‘Ok’;
} else {
echo Hash::make($password) . ‘
’;
echo $this->data()->password;
}
while echo out those, I receive different results. any solutions for that?

Don’t use SHA256 for password hashing, it’s not suitable nor secure.

Instead, use https://www.php.net/manual/en/function.password-hash.php

3 Likes

Also every hashing attempt should give a unique result, that’s part of the security, the password_hash() function mentioned does that for you, just use password_verify() accordingly.

Sponsor our Newsletter | Privacy Policy | Terms of Service