Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm Complexity & Security: MD5 or SHA1?

Tags:

algorithm

hash

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?

like image 463
Starx Avatar asked Jun 01 '10 08:06

Starx


People also ask

What is complexity algorithm?

Algorithmic complexity is a measure of how long an algorithm would take to complete given an input of size n. If an algorithm has to scale, it should compute the result within a finite and practical time bound even for large values of n. For this reason, complexity is calculated asymptotically as n approaches infinity.

What are the types of algorithm complexity?

The complexity of an algorithm can be divided into two types. The time complexity and the space complexity.

What is algorithm complexity with example?

When we analyse an algorithm, we use a notation to represent its time complexity and that notation is Big O notation. For Example: time complexity for Linear search can be represented as O(n) and O(log n) for Binary search (where, n and log(n) are the number of operations).

How do you find the complexity of an algorithm?

If your algorithm runs in a time proportional to the logarithm of the input data size, that is log ⁡ ( n ) \log(n) log(n), then you have O ( log ⁡ ( n ) ) \mathcal{O}(\log(n)) O(log(n)) complexity. This type of complexity is usually present in algorithms that somehow divide the input size.


1 Answers

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

like image 94
sharptooth Avatar answered Sep 22 '22 23:09

sharptooth