The purpose of this programming project is write a C program

The purpose of this programming project is write a C program to implement a simple polyalphabetic cryplosystem that incorporates topics related to file VO. In particular, this programming assignment will read an input ile, encrypt or decrypt the fie based on the requested operation, and wite the results to an output file REQUIREMENTS As with all programs in this course, your program\'s output should initially display the department and course number, your name, yourEUID, and your e-mal address. This functionality will be implemented using a function Your il prompt the user whether he/she would ke to encrypt or decrypt a file. a valid response is not input you are to repeatedly re-prompt the user unti a valid response is inpu. . You wil then prompt the user to enter the name of the input file to read from and the output fle to write the resulting plaintext or ciphertext as appropriate. If there is a problem opening the fle, you will display a mearingful error and exit the program using the appropriate exit status. You may assume that the length of the fie name does not exceed 25 characters (26 with the terminating nul character). · Ifthere are no errors causing you to terminate the program, you wil then call a funcion that will process the input file (ie, encrypt or decrypt the input sle, as appropriate) and write the resuts to an output le based on the folowing requirements: 1. You will prompt the user to enter a S-letter key that will be used to encrypt or decrypt the file as appropriate for the operaion. You must read this 5- letter key as 5 separate characters e., you must five different char variables to account for each letter in the kev). You may assume that the 5-letter key consists of alphabetic characters, but they may be entered as either uppercase or lowercase. Ultimately, you may treat each character asuppercase so that your shift wil have a range of 0-25(where - 1, ete) The files that you will encrypt or dearypt will only contain uppercase alphabetic characters (A z), lowercase alphabetic characters (a ) blank space, a tab, or a newine character 3. The user-defined funcion to process the input and output fles should accept two parameters as a minimum, the input fle stream and the output fie stream, but it may ublize additional parameters as needed. You must process each file character-by-charact(ie.. using the get and put member functions). 4. You will handle encryption in the foloing manner a. You will encrypt all alphabetic characters, both uppercase and lowercase, using the correct user-entered key (either the irst second, tied, fourth, orth leter, based on the order fals within th plaintext fle). Uppercase characters should encrypt to uppercase characters and lowercase characters shoud encrypt to lowercase characters. For example, the key is D. A would be replaced with the B would be replaced by Y would be replaced by B, and 2 would be replaced by C. Smlaty, if the key is D, a would be replaced with the d, b would be replaced by ,, y would be replaced by b, and z would be replaced by c by a b· lfthe plaintext file contains white space, such as a blank space, a tab, or a newine character, you will do no encryption, but simply keep the white space daractas is and write it to the aphertext le.

Solution

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

            int i,j=0;

            int tmp1,tmp2;

            int dtln,kln,sum;

            char data[100],key[100],cipher[100];

            clrscr();

            printf(\"Enter String : \");

            gets(data);

            printf(\"Enter Key : \");

            gets(key);

            dtln=strlen(data);

            kln=strlen(key);

// Sender Side

            for(i=kln;i<dtln;i++)

            {

                        if(data[i]==32)

                        {

                                    i++;

                        }

                        key[i]=key[j];

                        j++;

            }

            for(i=0;i<dtln;i++)

            {

                   if(data[i]==32)

                   {

                        cipher[i]=\' \';

                        i++;

                   }

                   else if(data[i]<=90 && data[i]>=65)

                   {

                                    tmp1=data[i]-65;

                   }

                   else if(data[i]<=123 && data[i]>=97)

                   {

                                    tmp1=data[i]-97;

                   }

                   tmp2=key[i]-64;

                   sum=tmp1+tmp2;

                   if(sum>26)

                   {

                                    sum=sum-26;

                                    cipher[i]=sum+64;

                   }

                   else

                   {

                                    cipher[i]=sum+64;

                   }

            }

            cipher[i++]=\'\\0\';

            puts(cipher);

//RECEIVER SIDE

            printf(\"Receiver Side\ \");

            for(i=0;cipher[i]!=\'\\0\';i++)

            {

                   tmp1=cipher[i]-64;

                   tmp2=key[i]-65;

                   sum=tmp1-tmp2;

                   if(sum<0)

                   {

                                    sum=sum+26;

                                    cipher[i]=sum+64;

                   }

                   else{

                                    cipher[i]=sum+64;

                   }

            }

            cipher[i++]=\'\\0\';

            printf(“\ \ Cipher Text :”);

            puts(cipher);

            getch();

}

 The purpose of this programming project is write a C program to implement a simple polyalphabetic cryplosystem that incorporates topics related to file VO. In
 The purpose of this programming project is write a C program to implement a simple polyalphabetic cryplosystem that incorporates topics related to file VO. In
 The purpose of this programming project is write a C program to implement a simple polyalphabetic cryplosystem that incorporates topics related to file VO. In

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site