Question: Q5. a. [6 pts] Write a Haskell function subsEncrypt that outputs a string which is the substitution code encryption of a string given to it

 Q5. a. [6 pts] Write a Haskell function subsEncrypt that outputs

Q5. a. [6 pts] Write a Haskell function subsEncrypt that outputs a string which is the substitution code encryption of a string given to it as its first argument using the key that is given to it as its second argument. The key is a 27 character string showing the replacements for each letter in the 26 letter English alphabet in alphabetical order and the empty space symbol at the end. For example, if the key is the string "bcdeafghijklmnopgrstuvwx XZ, the letter 'a' in the input will be replaced by letter 'b' in the output, empty space in the input will be replaced by letter 'z' at the output, and letter 'y' in the input will be replaced by the empty space at the output, etc. (Hint: You may use the functions fromEnum and toEnum as in Homework4. You may use (!! n) to take the n th element of a list starting from 0.) b. [6 pts] Write a Haskell function subsDecrypt that decrypts its input string encrypted by the function in part a using the key provided to it as the second argument as in part a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!