I used the crypt function with the blowfish algorithm(one-way hashing)and i saved my hashed string in db there no problem.
$hash=$2y$13$1wVxPniVSiKTjBmDxUhykeec08.v0UsujEkmhjHECIUgEiSuJFag
$actual=crypt("kumar",$hash);
These is how they used to validate the password is to took our current password and the hashed password which we can stored into the db.
On during these they compared with follwing code
public function compareString($expected, $actual)
{
$expected .= "\0";
$actual .= "\0";
$expectedLength = StringHelper::byteLength($expected);
$actualLength = StringHelper::byteLength($actual);
$diff = $expectedLength - $actualLength;
for ($i = 0; $i < $actualLength; $i++) {
$diff |= (ord($actual[$i]) ^ ord($expected[$i % $expectedLength]));
}
return $diff === 0;
}
It return only 0 or 1 when the password is correct or not.
But My question is on these how they matched the current password with the hashed password which we save in db.Because the current password only contains the string and the hashed password contains the cost,salt,hashed password.
Is that they validate the password only or only the salt or how they do it?
I want the flow of validation of passwords of In-built crypt algorithm.