Question: If we were encrypting a file, the program would be specified the name of a text file containing some text, say, Hello World. After encrypting

If we were encrypting a file, the program would be specified the name of a text file containing some text, say, "Hello World". After encrypting the file, the text file would then read "Ifmmp Xpsme", as the encryption algorithm will have substituted each character with another one using the key value provided by the user. If the source file contained "Ifmmp Xpsme", then decrypting with the same key value would restore the original "Hello World" message. The program will be sensitive to the following command line arguments: -e or -d: These flags will indicate if the program is encrypting or decrypting a file -k X: This flag specifies the key value, X, where X could be any integer value -i : This flag specifies the input file, or source file, containing the text to be encrypted or decrypted. Substitute with your input file name. -o : This flag specifies the output file, which has the results are written to. If the executable was named "test", an example command line execution of this application may look as follows: ./test -e -k 5-i input.txt -o output.txt This command would then read from a file named "input.txt" and write to "output.txt", encrypting the contents of "input.txt" using the key value of 5. These command line arguments should also be flexible such that they can be specified in any order: ./test -i input.txt -o output.txt -k 5-e Another example showing a decryption would be as follows: ./test -d -k 5-i input.txt -o output.txt So, the point of the program is that if the user does not use the same key value to decrypt as they did to encrypt, they will not be able to restore the original message. This will be due to the encryption method. Encryption Method To perform the encryption, we will be using what is known as a Caesar cipher. The Caesar cipher encrypts text by taking the current character's alphabetic location and shifting it by some specified number, as indicated in the image below: XYZABCDEF A BCDE FGHI Where each letter of the alphabet is shifted by 3. This number is what was referred to as the "key" and must be specified by the user for encryption. Decryption works the same way, but in reverse: ABCDEFGHI XYZABCDEF Also, not the cyclic nature of the cypher, where letters at the end of the alphabet will cycle around to the beginning if the shift value is beyond the length of the rest of the alphabet. For example, if the key value is 1, Z gets mapped to A. When the user specifies encryption, the key value specified will be used to shift each letter of text by that amount. Requirements Your program will utilize the "argc" and "argv" main parameters to read in the command line arguments. Your program should be resilient to the order arguments where passed in Your program should display an error message if the input parameters were incomplete or missing The Ceasar cipher should be applied as indicated in the description above for encryption and decryption as specified by the user's input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!