by fashizzlepop on Wed Jan 02, 2013 4:14 pm
([msg=71961]see Re: [DHA]: A new hashing algorithm[/msg])
I ran a quick test on it by testing combinations of 3 characters ascii 32 to 126.
- Code: Select all
import itertools
** DHA function here **
def main():
print "[+] Running collision tester"
print "[+] Testing strings of length 1-3"
chars = ""
for i in range(32,126):
chars += chr(i)
print "[+] Testing strings with the following characters:\n" + chars
onechar = list(itertools.product(chars, repeat=1))
print "\n[+] Number of strings to test of length:\n\t1 char: " + str(len(onechar))
twochar = list(itertools.product(chars, repeat=2))
print "\t2 chars: " + str(len(twochar))
thrchar = list(itertools.product(chars, repeat=3))
print "\t3 chars: " + str(len(thrchar))
hashes = {}
total = onechar
total += twochar
total += thrchar
collisions = 0
for s in total:
#print "[+] testing '" + ''.join(s) + "'"
h = dha(''.join(s))
if not h in hashes:
hashes[h] = ''.join(s)
else:
collisions += 1
print "[-] " + ''.join(s) + ":" + h + " matches " + hashes[h] + ":" + h
print "[-] Total collisions found: " + str(collisions)
It found 283915 collisions in combinations of just 3 characters...
It appears that # and / and , within strings caused many collisions. With just 2 char strings there are still plenty of collisions and it won't take as long to run as it does with 3 if you want to see the collisions for yourself. Just wrap your script up in a function call dha()
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.