Example 94: Encryption and Decryption of a File
Write a program to encrypt/decrypt a file using a substitution cipher. The file
sample.txt has already been written for you.
In this cipher, each character read from the source file is substituted by a corresponding predetermined character, and this character is written to the target file.
For example, if the character A is read from the source file, and if we have decided that every A is to be substituted by !, then a ! would be written to the target file in place of every A.
Similarly, every B would be substituted by 5, and so on.