Tag Info

New answers tagged

-2

Use something more collision resistant like SHA... I can't find any hashes that are completely collision proof, but sha at least decreases the collisions...


2

As far as I understand, the scheme is: $$MD5(x) = a_1||a_2||a_3||a_4 \, \, \Longrightarrow \, \, H(x) = a_1 \oplus a_2 \oplus a_3 \oplus a_4,$$ with $a_i$ 4-byte/32-bit words. Obviously you can't guarantee a unique 32-bit hash from an unbounded domain, due to the pidgeonhole principle. Neither can you make finding collisions infeasible, since $2^{16}$ MD5 ...


0

You cannot escape the birthday bound - it will eat your lunch lunch every time. MD5 has a good uniform distribution, so should your algorithm. Since it outputs 32-bit values, you should expect collisions after around $\sqrt{\frac{\pi}{2}2^{32}} = 82137$ hashes.


1

python code: import hashlib, sys hashDict = {} total = 10000000 for i in xrange(1,total): hashd = hashlib.sha1(str(i)).hexdigest() relev = hashd[:10] if relev in hashDict: print " *** Collision found ", hashDict[relev], " and ", i sys.exit(0) hashDict[relev] = i Could be made slicker, but I was just typing the first ...



Top 50 recent answers are included