123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Encryption/Decryption

--------------------------------------------------------------------------------

Description : This program encrypt and Decrypt a given input file.

#include<stdio.h>

void main()
{
FILE *fp,*fp1;
int choi;
char name[20],temp[20]={"Temp.txt"},c;
clrscr();
printf("

Press 1 to Encrypt:
Press 2 to Decrypt");
printf("

Enter your Choice:");
scanf("%d",&choi);
switch(choi)
{
case 1:
printf("Enter the filename to Encrypt:");
scanf("%s",name);
fp=fopen(name,"r+");
if(fp==NULL)
{
printf("The file %s can't be open",name);
getch();
exit();
}
fp1=fopen(temp,"w+");
if(fp1==NULL)
{
printf("The file Temp can't be open");
getch();
exit();
}
c=fgetc(fp);
while(c!=EOF)
{
fputc((c+name[0]),fp1);printf("%c",c+name[0]);getch();
c=fgetc(fp);
}
fclose(fp);
fclose(fp1);
remove(name);
rename(temp,name);
printf("The file is Encrypted:");
getch();
break;
case 2:
printf("

Enter the Filename to Decrypt:");
scanf("%s",name);
fp=fopen(name,"r+");
fp1=fopen(temp,"w+");
c=fgetc(fp);
while(c!=EOF)
{
fputc(c-name[0],fp1);
c=fgetc(fp);
}
fclose(fp);
fclose(fp1);
remove(name);
rename(temp,name);
printf("The file is decrypted:");
getch();
}
}

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG