Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is a dictionary that contains 5 sha1 hash values. These hash values were cr

ID: 3884618 • Letter: H

Question

Here is a dictionary that contains 5 sha1 hash values. These hash values were created by hashing hex values (as strings) as provided in the example. All originated from numbers smaller then 1,000,000. 1. Can you complete the dictionary and replace the ?? by the original values? If so, create a function "get_hash_dict()" that returns the completed dictionary. 2. Can you create a second function named "get_integer_values()" that returns a list (ordered from small to large) of the integer values instead of the hex values?

import hashlib

d = {}

d['208f1a0c208342372b75d914b6c098d626becf07'] = "??"

d['61fc7fbf6b24ff258633dad73f13f9bd66a2477f'] = "??"

d['8a57a79d7a9921cd2344e7295dc72359780e9f9d'] = "??"

d['bba1db3a9d5ba9f72b91312e730a9612dfdea053'] = "??"

d['350d5bf1074e5557367a24ae9e07ab65aacfc031'] = "??"

#here is an example on how to use hashlib

value = "0x5FA"

value = value.encode("utf-8")

print(hashlib.sha1(value).hexdigest())

def bruteforce(): #here goes your code but this function should be never called on the #system here

return []

Explanation / Answer

import hashlib

def bruteforce(hash):
for x in range(0, 1000000):
if hashlib.sha1(hex(x).encode("utf-8")).hexdigest() == hash:
return x
return -1

def get_hash_dict():
d = {}
d['208f1a0c208342372b75d914b6c098d626becf07'] = bruteforce('208f1a0c208342372b75d914b6c098d626becf07')
d['61fc7fbf6b24ff258633dad73f13f9bd66a2477f'] = bruteforce('61fc7fbf6b24ff258633dad73f13f9bd66a2477f')
d['8a57a79d7a9921cd2344e7295dc72359780e9f9d'] = bruteforce('8a57a79d7a9921cd2344e7295dc72359780e9f9d')
d['bba1db3a9d5ba9f72b91312e730a9612dfdea053'] = bruteforce('bba1db3a9d5ba9f72b91312e730a9612dfdea053')
d['350d5bf1074e5557367a24ae9e07ab65aacfc031'] = bruteforce('350d5bf1074e5557367a24ae9e07ab65aacfc031')
return d

d = get_hash_dict()

def get_integer_values(d):
res = list(d.values())
res.sort()
return res

print (get_integer_values(d))

# code link: https://paste.ee/p/ytnCE

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote