I am trying to understand password_hash fully in order to be able to explain it for an auditor.
Based on my searching for an answer, I understand that the password_hash()
function is a wrapper for crypt()
. While reading the PHP manual for predefined Constants I see that it uses PASSWORD_BCRYPT
as the default integer value (basically it uses the CRYPT_BLOWFISH
algorithm to hash a password).
What's confusing me is that the $options
variable, if omitted, generates a random salt and the cost will be set to 10
. If I supply a higher cost (for example: 12
), will it still generate a random salt since I am not supplying a salt value? The reason why I am confused here is because I am not omitting the $options
but instead supplying a different cost.
My other questions:
- Why does increasing the cost value increase security?
- How, since
password_hash()
is a one way hashing function, doespassword_verify()
validate the password since the salt is random? - Is
CRYPT_SHA512
stronger thanCRYPT_BLOWFISH
for hashing?