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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f519d2a2460_96266f519d232476.jpg)
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
Get step-by-step solutions from verified subject matter experts
