You’re going to owe me a 5* review after this @agentmishra ??
————————————
Dear Blesta support,
I need to be able to validate a user’s password from the database using an external system using PHP.
Given a function that receives the plain text password and the hash for the user stored in the database I am struggling to see how I can validate the password.
I believe it should look something like the following but I am unsure of the key that would need to be passed into the hash_hmac function (see this currently replaced with question marks:
function validatePasswordAgainstHash($password, $hashFromDatabase) {
$hmacHashFromPassword = hash_hmac('sha256', $password, '?????????????');
$resultAfterBcrypt = password_verify($hmacHashFromPassword, $hashFromDatabase);
return $resultAfterBcrypt;
}
Am I close?
Thank you for your support.
——————————————–
You now need to work with them to get it working on your local code.
You can try running this function with their modifications and passing in the data you’ve given me and making sure it returns true. E.g.
function validatePasswordAgainstHash(
'$2y$12$37Vz4b3gvYtpfEoFfB2uyOvL7kt0gfnW.m.584aMqqaBADVA0YQiS',
'password'
) {
$validated = // Whatever code they suggested here
if ($validated) {
error_log('Validated')
} else {
error_log('Not validated')
}
return $validated;
}
If you could write a review I’d be grateful.
Thanks,
Tom