Algorithm Complexity & Security: MD5 or SHA1?

AlgorithmHash

Algorithm Problem Overview


>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?

Algorithm Solutions


Solution 1 - Algorithm

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

Solution 2 - Algorithm

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

enter image description here

Solution 3 - Algorithm

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStarxView Question on Stackoverflow
Solution 1 - AlgorithmsharptoothView Answer on Stackoverflow
Solution 2 - AlgorithmBiswajit KarmakarView Answer on Stackoverflow
Solution 3 - AlgorithmAlanView Answer on Stackoverflow