Cryptography is the study of techniques for securing data for communication in the presence of adversaries. The data or message that is to be communicated is encrypted (converted from a readable state to apparent nonsense) by the originator. The encryption technique is shared only with the receiver of the message so that only he can decrypt the message.
One of the early forms of encryption is that used by Julius Caesar of the Roman Empire where he would encrypt his messages to his military generals. He would shift each letter in his original message by 3 places, which would appear meaningless in case it was intercepted. For example, if his original message was:
MEET AT THE ELEPHANT LAKE AFTER SUNSET ON SUNDAY
He would substitute each letter by the letter 3 places after it in the alphabet. Thus, the encrypted message would become:
PHHW DW WKH HOHSKDQW ODNH DIWHU VXQVHW RQ VXQGDB
The receiver of the message would then shift the letters 3 places backwards to retrieve the original message.
Write 2 programs:
1. An encryptor that will encrypt the message according to Caesars technique mentioned above. The encryptor will read the message from the keyboard and save the encrypted message into a file called data.encrypt. It should be able to accept a message that consists of multiple lines. Assume that the message only consists of the upper case letter AZ, the space character, and the newline character. You will only shift the letters and leave the space and newline characters as is. Make sure to shift the letters X, Y, and Z to A, B, and C.
2. A decryptor that the receiver of the encrypted message can use to decrypt the message. The decryptor will read the saved data.encrypt file and display the decrypted message on the screen.
Note: You may also choose to write one program and ask the user whether he wants to encrypt or decrypt
1. You may wish to follow the following design for the encryptor:
2. And the following design for the decryptor:
3. The following functions may be useful: