Algorithm Complexity & Security: MD5 or SHA1?

Which is the best overall hashing algorithm in terms of complexity and security? md5 or sha1?

From what I know md5 is faster than sha1 but SHA1 is more complex than md5.

Am I missing anything?


First of all, MD5 is broken - you can generate a collision, so MD5 should not be used for any security applications. SHA1 is not known to be broken and is believed to be secure. Other than that - yes, MD5 is faster but has 128-bit output, while SHA1 has 160-bit output.

Update: SHA1 has been broken: a team of researchers at Google and CWI have published a collision - https://shattered.io/static/shattered.pdf


Here is the comparison between MD5 and SHA1. You can get a clear idea about which one is better.

enter image description here


MD5 is not suitable for use for with any sort of sensitive information. Collisions exist with the algorithm, and there have been successful attacks against it.

At the time of this update (3/2017) SHA-2 is now preferred.

When ever you embark on securely dealing with information, it is recommended that you check the latest guidelines.