Jul-24-2019, 05:41 AM
so I am trying to create a python program that will give me a final hash that has been provided for me Final Hash: 42EE53E049F4E104BF81A517C5ED52BE2D94487A253FCF978CE783A3529794BC using the following 5 hash values: hash1: F7002A5259567B1F993E743D3128B6A97B153EACFC7BB914802DCFB43D23FA2E hash2: 6E2B86DC5982F533C3A896E66B97D377D09E7988B7E27E9BE5DDBA9F34C325FC hash3: 83AAB3327FFF40207AEB5919BD7FB06BAE953324FC71EE35816076CD6480334A hash4: 0B794C734A46D75BE2EEE543F714E8D7E2D41D0549D4D8E1167B77B63080DE83 hash5: EC40BD8242061EF401305485800CA5D63A9AB6DA659221A27C7BFAD3A9694E6C as well as an initial hash of: initial hash: E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
Those 5 hashes and the initial value need to match up to the final hash.
I have tried to create a while loop, and I have tried to reorder the hash values for example instead of "1,2,3,4,5" I have tried "3,5,4,1,2" to see if I get the final value.
I've tried to rearrange the hex values but still cannot figure it out.
Those 5 hashes and the initial value need to match up to the final hash.
I have tried to create a while loop, and I have tried to reorder the hash values for example instead of "1,2,3,4,5" I have tried "3,5,4,1,2" to see if I get the final value.
import hashlib chain = hashlib.sha256() #Hash 1 hash_1 = hashlib.sha256(b"This is my first hash") hex_dig = hash_1.hexdigest().upper() print("\nOld:",hex_dig) #Hash 2 hash_2 = hashlib.sha256(b"This is my second hash") hex_dig2 = hash_2.hexdigest().upper() print("\nOld:",hex_dig2) #Hash 3 hash_3 = hashlib.sha256(b"This is my third hash") hex_dig3 = hash_3.hexdigest().upper() print("\nOld:", chain.hexdigest().upper()) #Hash 4 hash_4 = hashlib.sha256(b"This is my forth hash") hex_dig4 = hash_4.hexdigest().upper() print("\nold:", chain.hexdigest().upper()) #Hash 5 hash_5 = hashlib.sha256(b"This is my fifth hash") hex_dig5 = hash_5.hexdigest().upper() print("\nOld:", chain.hexdigest().upper()) print("\nUpdated Chain\nAdding:\t",hash_3.hexdigest().upper()) chain.update(hash_3.digest()) print("New:\t",chain.hexdigest().upper()) print("\nUpdated Chain\nAdding:\t",hash_1.hexdigest().upper()) chain.update(hash_1.digest()) print("New:\t",chain.hexdigest().upper()) print("\nUpdated Chain\nAdding:\t",hash_2.hexdigest().upper()) chain.update(hash_2.digest()) print("New:\t",chain.hexdigest().upper()) print("\nUpdated Chain\nAdding:\t",hash_5.hexdigest().upper()) chain.update(hash_5.digest()) print("New:\t",chain.hexdigest().upper()) print("\nUpdated Chain\nAdding:\t",hash_4.hexdigest().upper()) chain.update(hash_4.digest()) print("New:\t",chain.hexdigest().upper()) print("\nFinal Chain:\n", chain.hexdigest().upper()) chain = hashlib.sha256() print("\nInitial Chain:\n",chain.hexdigest().upper())I expect the output to be Final Chain: 42EE53E049F4E104BF81A517C5ED52BE2D94487A253FCF978CE783A3529794BC
I've tried to rearrange the hex values but still cannot figure it out.