Alright so Im trying to verify password with SHA 512, but no matter what it still returns false like the hash check is not correct.
Generating hash when registering
$hashed = password_hash(hash('sha512', $password), PASSWORD_DEFAULT);
And to verify (upon login) I use simple
public function isValidLogin($username, $password) {
$sql = $this->connect();
$sql->real_escape_string($username);
$sql->real_escape_string($password);
$res = $sql->query("SELECT password FROM users WHERE name='".$username."'");
if ($res->num_rows >= 1) {
while($row = $res->fetch_assoc()) {
if (password_verify(hash('sha512', $password), $row['password'])) {
return true;
}
}
}
return false;
}
password
? Everything looks good: sandbox.onlinephpfunctions.com/code/… – Confluent$hashed
is written to database completely. – Superintendent9db2fda4438e3180bc3440b6ef52c98b58be9b657bf031f824bf9882d813f0c5b0ada477dad414ac188a758da49fc5236396652b0dc140a6629a62abcbe6b78b
– Indemnify$sql->real_escape_string($username);
does nothing with the returned value. You need to assign the result to something like$username = $sql->real_escape_string($username);
– Muleteer