Question: Assignment 3 will use code from assignment 2 to encrypt and decrypt a plaintext ( p ) string of characters, the digits 0 - 9

Assignment 3 will use code from assignment 2 to encrypt and decrypt a plaintext (p) string of characters,
the digits 0-9 and two special characters, a question mark ? and a square bracket ]. The plaintext will
not contain spaces or other characters (e.g.@,*,etc.). New to assignment 3 will be the use of functions,
array parameters and file input/output (I/O), including two user-defined functions named encrypt and
decrypt described in this handout. For file I/O the commmand line arguments from Assignment 2 will
be stored in a configuration file and the name of the configuration file will be the only command line
argument for Assignment 3.
For this assignment, the encryption and decryption code in main from Assignment 2 needs to be placed
into two functions named encrypt and decrypt. Also, the the codebook, plaintext and ciphertext input
will be input as files instead of the command line. The only command line argument in A03 will be a
configuration file that contains the names of the input and output files, the shift amount (-k), an option
to encrypt (-e) or decrypt (-d), and the codebook filename.
Refer to the code listing for details about all the functions to write. The encryption and decryption
algorithm (shift cipher) stays the same as described in the handout for assignment 2.
For A03, the sourcecode files defs.h with the configuration struct, A03.h file with function proto-
types, A03.cpp with the empty function definitions, an example autograder.cpp driver file, and the
codebook.csv have been provided in A03.zip. Read in the contents of the codebook.csv file and store
the values in a character array named codebook: char codebook[64];. Pass the codebook array to
your encrypt and decrypt functions. This approach differs from assignment 2 when codebook was a
global variable.
Your A03 program will accept a single command line argument that is the name of the configuration
file. The contents of an example configuration file to encrypt are shown below:
-k 5
-i plaintext.txt
-o ciphertext.txt
-e
-c codebook.csv
To decrypt, replace -e with -d and the input and output filenames in the configuration file.
Program Description and Functionality: Provide the following in your source file:
1. Comments at the top of your .cpp file.
2. Use the A03.cpp skeleton code file and implement all the defined functions
3. Use only C++ headers that place all standard-library routines in namespace std. For C++
file stream I/O use #include.
4. The use of command line arguments (int argc, char* argv[]) will be used to get the configuration
filename and is hardcoded as argv[1] in the example autograder.cpp application. Ensure your code
exits without an error if the filename argument is not provided.
5. The characters for the codebook array are stored as a comma separated list in a file named
codebook.csv and are the same character-set used in A02.
1)Z ,z ,Y ,y ,X ,x ,W ,w ,V ,v ,U ,u ,T ,t ,S ,s ,R ,r ,Q ,q ,\
2)P ,p ,O ,o ,N ,n ,M ,m ,L ,l ,K ,k ,J ,j ,I ,i ,H ,h ,G ,g ,\
3)F ,f ,E ,e ,D ,d ,C ,c ,B ,b ,A ,a ,9,8,7,6,5,4,3,2,\
4)1,0,?,]
6. Implement the functions to assist with encrypting, decrypting and reading and writing the files for
assignment 3. Refer to the following code listing for the function specifications.
1/* A3 : Write two functions encrypt and decrypt .*/
2 void encrypt ( std :: string & plaintext , int k , char codebook [], int codebook_length );
3 void decrypt ( std :: string & ciphertext , int k , char codebook [], int codebook_length );
4
5/* A3 : Use the following struct to hold the current configuration .
6 provided in the defs . h file */
7
8 struct Configuration {
9 int k =0;
10 std :: string config_filename ="" ;
11 std :: string codebook_filename ="" ;
12 std :: string infile ="" ;
13 std :: string outfile ="" ;
14 bool encrypt = true ;
15};
16
17/* A3 : Write a function to parse the configuration file and
18 initialize a configuration struct .
19
20 Tip : The configuration struct must be a reference or else no changes
21 will be preserved from the calling function */
22
23 void par se_config_file ( Configuration & c )
24
25/* A3 : Write a function read_codebook to read in the codebook . csv file .
26
27 Tip : this function requires the configuration filename
28 read in from the command line arguments and stored in
29 the configuration Struct string member variable : c . codebook_filename */
30
31 void read_codebook ( Configuration & c , char codebook [], int length )
32
33/* A3 : Write a function to read the plaintext or ciphertext message from the infile
34
35 Tip : the Configuration struct c will contain the string c . infile name
36 the msg is the same variable from A02*/
A3 Tasks : Implementation File A0(I submitted SS top right is A02 encrypr decrypt code if u need it.) Top left pic is what i need
Assignment 3 will use code from assignment 2 to

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 Programming Questions!