Question: Problem 7. We use affine ciphers modulo 26 to allow us to encode all 26 letters in the English alphabet, and we ignore all other
Problem 7. We use affine ciphers modulo 26 to allow us to encode all 26 letters in the English alphabet, and we ignore all other symbols to stay within these 26 characters. If we want to encrypt and decrypt faithfully all US English texts, including numbers, spaces, punctuation, and proper capitalization, we will need to allow the encryption and decryption functions to handle all printable ASCII characters - these have ASCII codes from 32 to 126 . If we use the codes 0,1,,94 for the ASCII characters with codes 32,33,,126, this will require us to use affine cipher modulo 95 : the key will be a pair (a,b) such that 0a,b94, with gcd(a^,95)=1. (a) Write encryption and decryption functions, Enc (x) and Dec (x), that implement such an affine cipher modulo 95 with the key (47,64). Your functions should: (i) take as inputs strings; (ii) convert the input string to a list of ASCII codes, adjusted appropriately; (iii) process that list modulo 95; (iv) convert the answer back to a string and return that string as output. [To convert strings to ASCII and back, you will need to use the tools built into your programming language of choice. For the decryption function, you may want to use the function ModInv (a,n) from Problem 6 with n=95.] (b) Write encryption and decryption functions, Enc (x, key ) and Dec (x, key), that generalize the functions you wrote in part (a) to a generic key (a,b), passed as an input. (c) How many different affine ciphers of this kind are there
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
