问题
Fundamental difference between Hashing and Encryption algorithms
Preferred Method of Storing Passwords In Database
http://codahale.com/how-to-safely-store-a-password/
I am confused about two things. If PHP 7.0 bcrypt provides a randomized salt. How are we supposed to retrieve it for password verification?
I understand there key stretching functions like PBKDF2 but can someone explain to me why a memory intensive hashing algorithm like scrypt is preferred over something like bcrypt? Besides the brute-force attack aspect. From the logic I've read online, people recommend using scrypt with multiple iterations.
回答1:
First question about bcrypt
and salt: salt is contained inside the result string as well as the cost, along with the hashed string. Each of three strings has constant length and thus can be retrieved easily thereafter.
For a more thorough explanation, see this answer.
scrypt
is a newer version of bcrypt
that requires more RAM to operate. The reason behind the RAM requirements is that CPU cycle based encryption (I/O based) is easily brute-forced using a modern GPU, multiple cores, etc. RAM on the other side is not so easy to scale, so a combination of increased RAM + multiple operations is theoretically a safer way.
Read more about this in this great answer.
来源:https://stackoverflow.com/questions/34409997/correct-way-to-store-passwords-in-php