5. Encrypt Caesar cipher is a kind of substitution cipher. Instead of using a substitution table, the alphabets are rotated by a number (a key). For example, if the key is 3, plaintext alphabet a would become d, and plaintext alphabet z would become c. Write a program that implements the Caesar Cipher. You program will first prompt for the key and then for the mode (E for encryption and D for decryption) and finally for the message to be encrypted / decrypted. Your program will then output the encryption / decryption message. For this question, the input message may consists of any character, the program should encrypt or small letter case a to z only. All other characters should be kept intact after encryption or decryption. Examples: Key: 3 Mode: E Message: i love you 1 oryh brx Key: 3 Mode: D Message: 1 oryh brx i love you Key: 26 Mode: E Message: i love you i love you
Encrypt
Caesar cipher is a kind of substitution cipher. Instead of using a substitution table, the alphabets are rotated by a number (a key). For example, if the key is 3, plaintext alphabet a would become d, and plaintext alphabet z would become c.
Write a
For this question, the input message may consists of any character, the program should encrypt or small letter case a to z only. All other characters should be kept intact after encryption or decryption.
Step by step
Solved in 3 steps with 1 images