3

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.

Community
  • 1
  • 1
White Lotus
  • 353
  • 2
  • 6
  • 16
  • have a look upon this http://stackoverflow.com/questions/33108720/password-hash-returns-different-value/33109078#33109078 – Linus Dec 22 '15 at 07:17
  • @Anmol thanks, not sure why I couldn't find this post. – White Lotus Dec 22 '15 at 07:19
  • why Scrypt is not recommended http://blog.ircmaxell.com/2014/03/why-i-dont-recommend-scrypt.html – Linus Dec 22 '15 at 08:00
  • Bcrypt hashes store the salt within the hash between one off the $ delimiters. You don't need to store the salt externally. [$2y$10$TwentytwocharactersaltThirtyonecharacterspasswordhash](http://stackoverflow.com/questions/5393803/can-someone-explain-how-bcrypt-verifies-a-hash) example of how it works – Crecket Jan 04 '16 at 12:40

1 Answers1

2

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.

Community
  • 1
  • 1
Sergey Telshevsky
  • 12,077
  • 6
  • 55
  • 78