Which has the least collision for a unique str: md5 or sha1

I want to create a unique hash for a given string and I was wondering if there is a difference in the duplicate hashes for md5 and sha1.

Lets use the following code for the argument:

foo = "gdfgkldng"
bar = "fdsfdsf"
md5(foo)
>>>> "25f709d867523ff6958784d399f138d9"
md5(bar)
>>>> "25f709d867523ff6958784d399f138d9"

      

Is there a difference in the likelihood of this between sha1 and md5? Also: if I use strings with a lot of overlap ("blabla1", "blabla2") is there a difference?

BTW. I am not interested in the security of algorithms, I just want to create a hash that is as unique as possible.

+3


source to share


1 answer


MD5 has a digest size of 128 bits. SHA-1 has a digest size of 160 bits. Even ignoring the discovered flaws, MD5 will produce more collisions just because it has less output space.



Consider SHA-256 instead; it has a digest size of 256 bits (obviously), and furthermore, it hasn't been broken in a meaningful way.

+5


source







All Articles