Parsi Coders
سورس کد اینکریپت و دیکریپت (سی) - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: C and C++ (http://parsicoders.com/forumdisplay.php?fid=54)
+--- موضوع: سورس کد اینکریپت و دیکریپت (سی) (/showthread.php?tid=2441)



سورس کد اینکریپت و دیکریپت (سی) - Amin_Mansouri - 06-16-2012

کد:
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();
  }
}



RE: سورس کد اینکریپت و دیکریپت (سی) - one hacker alone - 07-07-2012

الگوریتم کار رو کاش توضیح میدادی