Question: Assignment 3 will use code from assignment 2 to encrypt and decrypt a plaintext ( p ) string of characters, the digits 0 - 9
Assignment will use code from assignment to encrypt and decrypt a plaintext p string of characters,
the digits and two special characters, a question mark and a square bracket The plaintext will
not contain spaces or other characters eg@etc. New to assignment will be the use of functions,
array parameters and file inputoutput IO including two userdefined functions named encrypt and
decrypt described in this handout. For file IO the commmand line arguments from Assignment will
be stored in a configuration file and the name of the configuration file will be the only command line
argument for Assignment
For this assignment, the encryption and decryption code in main from Assignment 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 A 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
For A the sourcecode files defs.h with the configuration struct, Ah file with function proto
types, Acpp with the empty function definitions, an example autograder.cpp driver file, and the
codebook.csv have been provided in Azip. Read in the contents of the codebook.csv file and store
the values in a character array named codebook: char codebook; Pass the codebook array to
your encrypt and decrypt functions. This approach differs from assignment when codebook was a
global variable.
Your A 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
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:
Comments at the top of your cpp file.
Use the Acpp skeleton code file and implement all the defined functions
Use only C headers that place all standardlibrary routines in namespace std For C
file stream IO use #include.
The use of command line arguments int argc, char argv will be used to get the configuration
filename and is hardcoded as argv in the example autograder.cpp application. Ensure your code
exits without an error if the filename argument is not provided.
The characters for the codebook array are stored as a comma separated list in a file named
codebook.csv and are the same characterset used in A
Z z Y y X x W w V v U u T t S s R r Q q
P p O o N n M m L l K k J j I i H h G g
F f E e D d C c B b A a
Implement the functions to assist with encrypting, decrypting and reading and writing the files for
assignment Refer to the following code listing for the function specifications.
A : Write two functions encrypt and decrypt
void encrypt std :: string & plaintext int k char codebook int codebooklength ;
void decrypt std :: string & ciphertext int k char codebook int codebooklength ;
A : Use the following struct to hold the current configuration
provided in the defs h file
struct Configuration
int k ;
std :: string configfilename ;
std :: string codebookfilename ;
std :: string infile ;
std :: string outfile ;
bool encrypt true ;
;
A : Write a function to parse the configuration file and
initialize a configuration struct
Tip : The configuration struct must be a reference or else no changes
will be preserved from the calling function
void par seconfigfile Configuration & c
A : Write a function readcodebook to read in the codebook csv file
Tip : this function requires the configuration filename
read in from the command line arguments and stored in
the configuration Struct string member variable : c codebookfilename
void readcodebook Configuration & c char codebook int length
A : Write a function to read the plaintext or ciphertext message from the infile
Tip : the Configuration struct c will contain the string c infile name
the msg is the same variable from A
A Tasks : Implementation File AI submitted SS top right is A encrypr decrypt code if u need it Top left pic is what i need
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
