Write a program using Common Lisp that encrypts (encode)and decrypts (decode) a
ID: 3778074 • Letter: W
Question
Write a program using Common Lisp that encrypts (encode)and decrypts (decode) a phrase using the Caesar cipher.First convert all characters to numbers, A = 0, B = 1, C = 2, ..., Z = 25. The Caesar encryption function e(x), where x is the character being encrypted, is represented as e(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 e(x) = (x - k) (mod 26). Function Guidelines: 1) Function may only use recursion, 2) Each word of input must be read as a sub list of the list, and 3) No arrays, loops, or variables
Explanation / Answer
#include #include #include #include #include #define caesar(x) rot(13, x) #define decaesar(x) rot(13, x) #define decrypt_rot(x, y) rot((26-x), y) void rot(int c, char *str) { int l = strlen(str); const char *alpha[2] = { "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; int i; for (i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.