Question

QUESTION 2 (10 MARKS)A hash function is a way of taking a character string of any length, and creating an output of fixed length. This creates a 'fingerprint' of the character string. Hash functions usually use modular arithmetic to create a fixed length output.Your task is to design a hash function! Choose two character strings that are between 5 and 15 characters long (including spaces). For example. "Julia 123" or "Password!". (a) (i)Design a function h whose input is a character string of any length and whose output is a (base 10) whole number. Your function must make non-trivial use of the ASCII values of each character. (For example,add all the ASCII values together - but don't use this example!) (ii)Explain how your answer to (a)(i) satisfies the definition of a function. (b)Calculate the outputs of your function h for the two character strings you defined. (c)Choose a modulus m of between 4 and 12.Calculate the least residues modulo m of each of your two answers to (b),showing full working. (d)Give two reasons why it might be useful to create hash functions like these as a way of storing passwords in a database.

Question image 1Question image 2Question image 3Question image 4Question image 5Question image 6