06-16-2012، 09:03 PM
کد:
Encryption-Decryption#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();
}
}
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg