
In an environment where security is paramount, the messages stored in a file must have a format that is different from the meaning of the original message. Each character has a number in the ASCII chart. The messages stored in a file should be in the corresponding ASCII format. And if it?s a word, concatenate a letter w to show that the word still continues. When a space is encountered, add a word space. Change word by word until the end of the message which is later stored in a file. This is called encryption. When one wants to read the contents of the file, It should display the encrypted form and also the original version. Changing the copy to the original will be called decrypting. Eg
The cat is translated to 84w104w101space99w97w116 (hint: try printf("%d",'t');) Create code for this project including both the encryption and decryption aspects in ASCII format and only in C (NOT EVEN C++). Thank you.Please if possible post answers also to

#include<stdio.h>
void main(){
FILE *fp1,*fp2;
int choice;
char fname[20],temp[20]={"file.txt"},c;
clrscr();
printf("Press 1 to Encrypt");
printf("Press 2 to Decrypt");
printf("Enter your Choice:");
scanf("%d",&choice);
switch(choice){
case 1:
printf("Enter the filename to Encrypt:");
scanf("%s",fname);
fp1=fopen(fname,"r+");
if(fp1==NULL) {
printf("The file %s can't be open",fname);
getch();
exit();
}
fp2=fopen(temp,"w+");
if(fp2==NULL){
printf("The file Temp can't be open");
getch();
exit();
}
c=fgetc(fp1);
while(c!=EOF){
fputc((c+fname[0]),fp2);
printf("%c",c+fname[0]);
getch();
c=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
remove(fname);
rename(temp,fname);
printf("The file is Encrypted:");
getch();
break;
case 2:
printf("Enter the Filename to Decrypt:");
scanf("%s",fname);
fp1=fopen(fname,"r+");
fp2=fopen(temp,"w+");
c=fgetc(fp1);
while(c!=EOF){
fputc(c-fname[0],fp2);
c=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
remove(fname);
rename(temp,fname);
printf("The file is decrypted:");
getch();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.