May-07-2019, 01:38 PM
why do you need to complicate things that much? And you want the hash to be the key, not other way around.
import hashlib rainbow_dict = {} for i in range(1000, 10000): # note you need upper end to be 10000 in odrder to include 9999 my_hash = hashlib.sha256(str(i).encode()).hexdigest() rainbow_dict[my_hash] = i # or replace lines 3-7 with a single line #rainbow_dict = {hashlib.sha256(str(i).encode()).hexdigest():i for i in range(1000, 10000)} # sample with 3 random hashes passwords = ['c56b05eb525718f02df539e071361dd58b168a5a70abdb3148d44f98c46c38cd', 'f476ef220e571593579ae60582fe52a888309b21d4a01cf1cd56a14084d9db27', '1828526428f17576e6581a0b9c893ecf79c1fdc20f495f0bdc98b559b25b92a6'] for password_hash in passwords: print(f'{password_hash} --> {rainbow_dict[password_hash]}') print(hashlib.sha256('2523'.encode()).hexdigest() == passwords[0])
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs