CRYPTOGRAPHY(text file) in C PROGRAMMING

              JAYA ENGINEERING COLLEGE
MENTOR : SAM
                   (JAYA ENGINEERING COLLEGE)
DEPARTMENT : CSE - B
PROJECT DONE BY
1) Santhosh Kumar .R(CSE-B)
     110817104071
2) Solairaj S.T(CSE-B)
     110817104075
#include<stdio.h>
#include<stdlib.h>
int encrypt();
int decrypt();
FILE *fsrc,*fdes;
char ch;
int main()
{
int choice;
while(1)
{
printf("1 Encrypt \n");
printf("2 Decrypt \n");
printf("3 Exit \n");
printf("Enter your choice  :  ");
scanf("%d",&choice);
switch(choice)
{
case 1:encrypt();
        break;
case 2:decrypt();
        break;
case 3:exit(1);
break;
}
}
printf("\n");
}
int encrypt()
{
char src[25];
printf("\nEnter file name to Encrypt : ");
scanf("%s", src);
fsrc = fopen(src,"r");
if(fsrc == NULL)
{
printf("not found \n");
}
fdes = fopen("encrypt.txt","w");
if(fdes == NULL)
{
printf("not found \n");
}
while(1)
{
ch = fgetc(fsrc);
if(ch == EOF)
{
printf("end of the file\n");
break;
}
else
{
ch = ch + 10;
fputc(ch,fdes);
}
}
fclose(fsrc);
fclose(fdes);
printf("\n");
}
int decrypt()
{
printf("\n");
fsrc = fopen("encrypt.txt","r");
if(fsrc == NULL)
{
printf("not found \n");
}
fdes = fopen("output.txt","w");
if(fdes == NULL)
{
printf("not found \n");
}
while(1)
{
ch = fgetc(fsrc);
if(ch == EOF)
{
printf("end of the file\n");
break;
}
else
{
ch = ch - 10;
fputc(ch,fdes);
}
}
fclose(fdes);
fclose(fsrc);
printf("\n");
}

Comments

Post a Comment

Popular posts from this blog

AUTO DOGTAG GENERATING IN C PROGRAMMING

ASCII CODE OF CHARACTERS