First, i should say that I am relatively new to programming so please be gentle with me if this is a naive or dumb question.
Ok, so I am in the process of writing a small application, part of which will involve hashing user passwords. After researching the best way to do this, md5 appears as a suggestion, almost as many times as it appears in articles criticizing its use.
The alternatives are the likes of SHA-1 etc which are stronger and less likely to be cracked. This makes perfect sense.
To get to the point:
- Why is md5 still widely used for hashing
- Should I automatically discount md5 for hashing passwords, or are there specific use cases where its use would actually be better than other hashing mechanisms?
Neither MD5 nor SHA-1 should be used for hashing passwords. They are designed to be fast to compute, which is exactly what you don’t want. If people are using these hashing algorithms for hashing passwords, it’s likely because they don’t know about alternatives.
Instead you should be using something like bcrypt that is designed specifically for this purpose. It can be configured to be as hard to compute as you need. As computers get faster you can just add more rounds to the computation to make it take longer. This will slow down attackers who get hold of the hashes and try to use brute-force or dictionary based attacks to get the passwords.
Related