Question: Recall hash puzzles from Lecture 10. In this question, we will see how they work in practice. This question requires programming in a language

Recall hash puzzles from Lecture 10. In this question, we will see how they work in practice. This question

Recall hash puzzles from Lecture 10. In this question, we will see how they work in practice. This question requires programming in a language that has an implementation of SHA-256 hash function. You should use Python's hashlib for this purpose. Create an integer s containing all the digits in your student ID, followed by the current year, i.e., 2023. For example, if my student ID is 12345678, then s = 123456782023. Let "str" denote the string function, i.e., given any integer s. the function str(s) casts it into a string. For example, =123456782023 becomes str(s) = "123456782023". Set the target t to: 2256 26 Let H be the SHA-256 hash function. Let r be a counter starting from 1. Finally, let "|" denote string concatenation. 5 (a) Implement a program that tries successive values of r, ie., r = 1,2,3,.... computes H(str(r)||str(s)), compares it with t and halts whenever H(str(r)||str(s)) < t, with the output r. You need to provide the program and the output r. (5 marks) (b) Let us call the program from part (a) as: PuzzleFinder(s, t). Write a program that calls PuzzleFinder with successive inputs (s+i, t), for i=0 to 999, and records the output for each of these 1,000 runs. What is the average number of attempts in these 1,000 runs before you found the target? You need to provide your program. (3 marks) (c) If you want someone to take 260 attempts on average before they solve the puzzle, what should you set the target to and why? (2 marks)

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python program that implements the requirements described in parts a and b of the question python import hashlib def PuzzleFinders t r 1 while ... View full answer

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 Programming Questions!