Question: This Python code is not working, it keeps going to print(Preimage not found) Can you help with fixing the issue? Thank you, ------------------------------------------------------------------------------------------------------------------------------- import hashlib

This Python code is not working, it keeps going to print("Preimage not found")

Can you help with fixing the issue?

Thank you,

-------------------------------------------------------------------------------------------------------------------------------

import hashlib import time

def find_preimage(): target_hash = "bh2k2" chars = "abcdefghijklmnopqrstuvwxyz0123456789" for i in chars: for j in chars: for k in chars: for l in chars: for m in chars: message = i + j + k + l + m print("message: "+message) hash_value = hashlib.sha1(message.encode()).hexdigest()[:10] if hash_value == target_hash: return message return None

start_time = time.time() preimage = find_preimage() end_time = time.time()

if preimage: print("Preimage found: " + preimage) print("Time taken: " + str(end_time - start_time) + " seconds") else: print("Preimage not found")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!