3 ms·
Isn’t SHA2 the standard hashing algorithm? If not, what do people use now?
by farazzz 8y ago
Isn’t SHA2 the standard hashing algorithm? If not, what do people use now?
- Thriptic 8y agobcrypt is one example: https://auth0.com/blog/hashing-in-action-understanding-bcrypt/ https://auth0.com/blog/hashing-in-action-understanding-bcryp...
- hamandcheese 8y agoFor password hashing, you want the operation to be slow. That way it becomes infeasable for someone to brute force many passwords. SHA2 is very fast.
- deathanatos 8y agoIf I get any of this wrong, I claim Cunningham's Law. :) From the "Cryptographic Right Answers" [https://latacora.micro.blog/2018/04/03/cryptographic-right-answers.html#password-handling https://latacora.micro.blog/2018/04/03/cryptographic-right-a...]: > Latacora, 2018: In order of preference, use scrypt, argon2, bcrypt, and then if nothing else is available PBKDF2. > Avoid: SHA-3, naked SHA-2, SHA-1, MD5. SHA2 is a decent cryptographic hashing algorithm, that is true. But a cryptographic hashing algorithm isn't what you want when storing passwords, at least, not on its own. Some of the problems with just using a hash algorithm: same passwords have the same hash; hash algos are typically fast, so brute forcing can make many attempts quickly, and they can be pre-computed into rainbow tables. There are ways to fix this (salts, work factors), but generally you shouldn't "do it yourself."; functions like those named in the quote from Cryptographic Right Answers put all that together in a nice package. scrypt, I believe, even uses SHA-2 in its construction, but also solves the aforementioned problems. The "Purpose and operation" part of the Wikipedia article for PBKDF2 (also mentioned above) goes into some of this, as well (even if it is only recommended as a last resort, I think this paragraph is educational w.r.t. the problems around passwords): https://en.wikipedia.org/wiki/PBKDF2#Purpose_and_operation https://en.wikipedia.org/wiki/PBKDF2#Purpose_and_operation
- shawn 8y agoSHA2 is fine for guaranteeing integrity. But that's different from coming up with a way to store a password that can't be brute forced in a small amount of time. The goal is to make the hashing function expensive. That is a different goal than making it reliable or authentic.
- stef25 8y agoBack when I was a super junior php dev I stumbled across a post by Cal Henderson about using bcrypt https://www.iamcal.com/2012-06/use-bcrypt/ https://www.iamcal.com/2012-06/use-bcrypt/ His lib is can be dropped in to any project (that doesn't have something similar built in already) https://github.com/iamcal/lib_bcrypt https://github.com/iamcal/lib_bcrypt Anyone writing code has no excuse for not using this, it's not rocket surgery.
- highesttide 8y agoIt's worth noting that the current standard encryption and password hashing in the php core is great, with no external dependencies added
- astura 8y agoFor password storage? Bcrypt.