Question
Write a program using Common Lisp that encrypts and decrypts a phrase using the Caesar cipher. The Caesar cipher is one of the earliest known
Write a program using Common Lisp that encrypts and decrypts a phrase using the Caesar cipher. The Caesar cipher is one of the earliest known and simplest ciphers. It is a type of substitution cipher in which each letter in the plain text is shifted a certain number of places down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is named after Julius Caesar, who apparently used it to communicate with his generals. For your program use a shift of 5. First convert all characters to numbers, A = 0, B = 1, C = 2, ..., Z = 25. The Caesar encryption function enc(x), where x is the character being encrypted, is represented as enc(x) = (x + k) (mod 26). k is the shift or key applied to each letter. After the function is applied the resulting number must then be converted back to a letter. The decryption function is dec(x) = (x - k) (mod 26). Example using a shift or key of 5. plain text: programming languages cipher text: uwtlwfhhnsl qfslzfljx Your program must include two functions: 1) encrypt, which takes as input a phrase as a list and displays its cipher representation as a string not a list. 2) decrypt which takes as input a cipher and displays plain text as a string. Your program must run with the function encrypt and the function decrypt once the file has been compiled and loaded. That is, at the prompt you should type encrypt(program) or decrypt(uwtlwf ). Your input must be read and processed recursively as a list. Each word in the phrase must be a sublist of the list. For example, the phrase programming languages must be inputted as the list ((P R O G R A M M I N G) (L A N G U A G E S)) to be encrypted. The encrypted text uwtlwfhhnsl qfslzfljx must be inputted as the list ((U W T L W F H H N S) (Q F S L Z F L J X)) to be decrypted. Your program must be able to process any phrase. Your program must use only recursion. Do not use assignment statements. 1 No variables, arrays, loops, progn allowed. The output must be a string not a list. You must write your own functions whenever possible, instead of using bui lt-in functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started