Question
In this assignment, you will develop a program in C++ that encrypts a text file and decrypts a text file using a simple arithmetic cipher.
In this assignment, you will develop a program in C++ that encrypts a text file and decrypts a text file using a simple arithmetic cipher. The cipher algorithm will simply encrypt by adding an integer value to each character (i.e., byte) in the file and decrypt by subtracting the same integer value from each character in the file. On the command line, the user will submit the name of the program, followed by either "-e" or "-d" and a nonnegative integer value (a key) between 0 and 120 inclusive. The "-e" option is for encrypt, and the "-d" option is for decrypt. The text file will be submitted using file redirection on the command line.
Software Requirements
The program shall read through the contents of the file by means of standard input. This means that the user of the program shall use file redirection on the command line in order for the program to read an existing file. The program shall send its encrypted or decrypted output data to standard output.
The program shall first check the entries on the command line. If the entries are not correct, the program shall immediately print out a usage message and terminate. If the command line entries are correct, the program shall read through the input file character by character. As each character is read, the program shall encrypt the character (i.e., add the key) or decrypt the character (i.e., subtract the key), and write the character to the output file.
After the program detects the end of the input file, it shall send a message to standard error saying "Encryption is done" or "Decryption is done," and then terminate normally.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started