I'm attempting to understand how rainbow tables work and am trying to implement one in python but without much success.
I have some code which essentially creates a dictionary in a text file with plaintext strings mapped to their hashes, but can't figure out how to adapt this to generate a reduced rainbow table.
temp = itertools.product("abcdefghijklmnopqrstuvwxyz", repeat=5)
f = open("passwords.txt", "w")
for pw in temp:
p = ''.join(pw)
encode = hashlib.md5(p.encode()).hexdigest()
f.write(p + " " + encode + "\n")
f.close()
I've came across reduction functions and kinda understand them and so have defined one as:
def reduction(hash):
return hash[:5]
But I don't know what to do from here :(
How can I adapt this code to generate a reduced rainbow table?