Reference no: EM13161456
Write a program to do the enciphering. It should prompt the user for a message, and print out both the entered message and its corresponding ciphertext.
Input. The message to be enciphered. Here is what a correct input should look like (the red text is what you type):
Enter your message: WHENINTHECOURSEOFHUMANEVENTS
Output. The message to be enciphered and the corresponding ciphertext. Here is what the output corresponding to the above input should look like:
plain = "WHENINTHECOURSEOFHUMANEVENTS";
cipher = "WEITEOREFUAEETHNNHCUSOHMNVNS"
(note the double quotes around the plaintext and ciphertext).
Here is another example. The input is:
Enter your message: CALLMEISHMAEL
and the corresponding output is:
plain = "CALLMEISHMAEL"; cipher = "CLMIHALALESME"
Now write a program to decipher the messages. Again, it should prompt the user for a ciphertext, and print out both the entered ciphertext and the corresponding plaintext.
Input. The message to be deciphered. Here is what a correct input should look like (the red text is what you type):
Enter your ciphertext: WEITEOREFUAEETHNNHCUSOHMNVNS
Output. The message to be deciphered and the corresponding plaintext. Here is what the output corresponding to the above input should look like:
cipher = "WEITEOREFUAEETHNNHCUSOHMNVNS";
plain = "WHENINTHECOURSEOFHUMANEVENTS"
(note the double quotes around the ciphertext and plaintext).
Here is another example. The input is:
Enter your ciphertext: CLMIHALALESME
and the corresponding output is:
cipher = "CLMIHALALESME"; plain = "CALLMEISHMAEL"
Now we will combine the two parts you just did into a single program. This program asks the user to type 'e' to encipher or 'd' to decipher. If the user asks to encipher, the steps in the first part are to be followed; if to decipher, the steps in the second part are to be followed.
Input. Whether the message is plaintext and is to be enciphered, or whether the message is ciphertext and is to be deciphered, followed by the message. Here is what a correct input should look like (the red text is what you type):
e to encrypt, d to decrypt): e
Enter your message: WHENINTHECOURSEOFHUMANEVENTS
Your program must be able to handle either an 'e' (lower case) or 'E' (upper case) to indicate enciphering, and either a 'd' or a 'D' to indicate deciphering.
Output. The entered message and the corresponding ciphertext or plaintext. Here is what the output corresponding to the above input should look like:
plain = "WHENINTHECOURSEOFHUMANEVENTS";
cipher = "WEITEOREFUAEETHNNHCUSOHMNVNS"
(note the double quotes around the plaintext and ciphertext).
Here is another example. The input is:
e to encrypt, d to decrypt): D
Enter your ciphertext: CLMIHALALESME
and the corresponding output is:
cipher = "CLMIHALALESME"; plain = "CALLMEISHMAEL"