3 ms·
A related thing always worth emphasizing: hashes aren't necessary cryptographically secure! Hashing has many purposes besides security, and for that reason the
by CobrastanJorji 3y ago
A related thing always worth emphasizing: hashes aren't necessary cryptographically secure!
Hashing has many purposes besides security, and for that reason there are many hash libraries. If you plan on using hashes for something related to security or cryptography, you need to use a hash designed for that purpose! Yes, CRC hashing is really fast, and that's great, but it's not great when you use it for user passwords.
- remram 3y agoPassword-masking functions are not usually what's referred to as "cryptographically-secure hash", e.g. unsalted SHA-2 is one but not the other. For example resistance to enumeration or rainbow tables is not a requirement for cryptographic hash functions, but is important for good password-hashing functions. https://en.wikipedia.org/wiki/Cryptographic_hash_function https://en.wikipedia.org/wiki/Cryptographic_hash_function https://en.wikipedia.org/wiki/Password-hashing_function https://en.wikipedia.org/wiki/Password-hashing_function
- fbdab103 3y agoUnless you have really specific requirements (hashes/second, hash size no bigger than X characters, etc) is there any reason not to default to sha256? I still see newly released projects that choose md5. Like, sure, for the intended use case, probably nobody will construct a collision, but why even allow the possibility?
- franky47 3y agoIt's not much about collisions, more like predictability of the output. You can trivially construct a rainbow table of the most common N passwords and test a dump of SHA-256 hashes against it. Also, SHA-256 is vulnerable to length extension attacks, so it may not be suitable in some applications on variable-length inputs. Generally speaking, hashing user-provided data as-is is only a guarantee of integrity, not of authenticity (see HMAC), nor secrecy.