Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the shift cipher Submit the source code program, test cases, and the r

ID: 3659042 • Letter: I

Question

Implement the shift cipher Submit the source code program, test cases, and the results of test runs. Notice that your source code should have a good description and in-line comments (I just want the source code!)

Explanation / Answer

//Here is a Code for Shift Cipher #include #include #include #define TRUE 1 #define FALSE 0 #define my_letters 72 int main (int argc, char *argv[]) { /*-------------------Declaration of the variables------------------------------------------*/ FILE *input, *output, *dictionary; int i=FALSE, j=FALSE, k=FALSE, l=FALSE, v=FALSE; char ch, dict; char my_letter_array[my_letters]; char *ptr, *library; int key, correct_key=FALSE, number_matched=0; int user_input; int counter=FALSE, matches=FALSE; int compare=FALSE, cnt=FALSE; if(argv[4] != NULL) { key = atoi(argv[4]); } if(argv[1] != NULL) { user_input = atoi(argv[1]); } /*-------------------Command Line Arguments------------------------------------------------*/ if(argc < 4 || argc > 5) // Checks to see if the usage is correct. { printf(" Usage: (exectuable) (user_choice) (input_file) (output_file) (key_code) "); printf(" *****(key_code **only** if user_input is 1 or 2)***** "); // Prints this is the information if not inputed corectly. return(FALSE); } input = fopen(argv[2],"r"); // Open the input file. if ((user_input 3)) { printf(" That is not a valid encryption/decryption setting! (Must be between 1-3) "); return(FALSE); } if(argv[4] == NULL && user_input != 3) //Makes sure that a key is entered if user_input is 1 or 2. { printf(" A key value is needed in order to proceed (key = (0-72)) "); return(FALSE); } if ((key 72) && user_input != 3) //Makes sure that the key is not a neg or greater than 72. { printf(" A key value is needed in order to proceed (key = (0-72)) "); return(FALSE); } input = fopen(argv[2],"r"); // Open the input file. if( input == NULL) // Checks whether there is an input file. { printf(" File %s cannot open! ", argv[2]); // Prints this if not. return(FALSE); } output = fopen(argv[3], "w"); // Opens the output file. if( output == NULL) // Checks whether there is and output file. { printf(" File %s cannot open! ", argv[3]); // Prints this if not. return(FALSE); } dictionary = fopen("mydictional.txt", "r"); // Opens the dictionary file to check the words. if( dictionary == NULL) // Checks whether there is a dictionary file. { printf(" File dictionary.txt cannot open! "); // Prints this if not. } /*------------------Make the 72-letter alphabet--------------------------------------------*/ for(i=97; i