/Hashing

Primary LanguageJava

Hashing

Write a program P such that P (M, k) takes two input where M could be an arbitrary string and k is an integer. The program would randomly generate nonce values (64bit) until the hash (use SHA-256) of the message and nonce (i.e.,H(M||ni)) have the first k bits equal to zero(in your implementation, just concatenate nonce to the end of the message without adding any special characters between the message and the nonce). Once such a nonce is found,P should output ‘H(M||ni),ni,i’ where (M||ni) and I are in hexadecimal,i(number of tries) as integer and just one comma between them.•RunPwithM=‘I Love Data Security Class So Much. It is so great :)’ and k={2,4,6,8},for each k value, run theP10 times and report the average number of tries and the standard deviation of the tries needed to find the required nonce.