views:

213

answers:

3

Which is the best overall hash algorithm. md5 or sha1. From what I know md5 is faster that sha1 but SHA1 is more complex than md5.

I am missing anything

+2  A: 

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.

Also both MD5 and SHA1 are not "encryption" algorithms - they are hash algorithms meaning that you can't restore the data after passing it through the algorithm.

sharptooth
@sharptooth don't say that MD5 was broken, so we can't use it. the only success is now in generating collisions. If you have generic piece of data now there are no means to produce fake data with same MD5. all know collisions were generated in pair.
Andrey
SHA1 _IS_ broken. See http://www.schneier.com/blog/archives/2005/02/sha1_broken.html
ya23
@ya23: Never heard of that, thank you. But read what exactly is said there - a collision generation requires 2**69 hash computations. That's unbelievably long. Should we really be worried?
sharptooth
@sharptooth Yes, because as Bruce Schneier says, attacks only ever get better, not worse. What's slightly broken today may well be very broken in the future - so switching while you can is a good idea.
Nick Johnson
@Andrey, MD5 **is** broken however one look at it. Chosen prefix collision in hours on a PC. Preimage attack found. Fake SSL certificate. You name a cryptographic hashing quality, it fails.
KTC
@sharptooth, Wikipedia lists 2^63 for SHA-1 (and if it is flawed 2^52). Still, assuming system that can do 1 billion hash computations per second, you would need 292 years (if my math is correct). If you need to feel more secure you can switch to SHA-2.
Unreason
@Unreason: Don't forget there are botnets (whose computational power is up for sale) with 10-million+ computers. Using one of those large botnets brings your calculation from 292 years to 2.5 seconds. And remember, attacks are only getting better, and computers are only getting faster...
BlueRaja - Danny Pflughoeft
+2  A: 

I think that what you are missing firstly is that md5 and sha1 are not really encryption algorithms, they are for hashing.

High Performance Mark
A: 

Yes, you're missing quite a lot actually.

One, neither are encryption. Both are hashing algorithms.

Second, 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. SHA1 doesn't have any attacks against it, but there have research that suggest it is vulnerable, and so SHA2 is preferred, until SHA-3 is finalized by NIST.

Alan