Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Cyber Security
  3. Question
Cyber Security

Can password_verify php work with any arguments?

Asked by Amit Raj Mar 28, 2022 1.1K views 1 answer
Share

About this question

I already know how to use password_verify and password_hash functions, but I don't really understand how they work.


When I use them I do something like that:

$save_hash = password_hash( $password, PASSWORD_DEFAULT );

$check = password_verify( $password, $hash );

How can password_verify know the algorithm used, the salt and the cost? The PHP official documentation say this:


Note that password_hash() returns the algorithm, cost and salt as part of the returned hash. Therefore, all information that's needed to verify the hash is included in it. This allows the verify function to verify the hash without needing separate storage for the salt or algorithm information.


But I don't really understand why all that information is included in the hash, so a possible attacker will know too. So, if attackers know the salt, why is it secure? They only have to put the salt at the beginning and try a brute force attack the same way they would do without a salt. What am I wrong about?

Your answer

1 Answer

More Cyber Security discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Cyber Security Blogs

Guides, tips and career advice on Cyber Security from JanBask experts.