加解密

#include "stdafx.h"

void Encry(char *infile,char *outfile)
{
FILE *fp1;
fp1=fopen(infile,"r");
FILE *fp2;
fp2=fopen(outfile,"w");
char ch=0;
ch=fgetc(fp1);
while(ch!=EOF)
{
fputc(ch+1,fp2);
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
remove(infile);

}

void Unencry(char *infile,char *outfile)
{
FILE *fp1;
fp1=fopen(infile,"r");
FILE *fp2;
fp2=fopen(outfile,"w");
char ch=0;
ch=fgetc(fp1);
while(ch!=EOF)
{
fputc(ch-1,fp2);
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
remove(infile);
}

int _tmain(int argc, _TCHAR* argv[])
{
char infile[100],outfile[100];

printf("please input file path:\n");
scanf("%s %s",infile,outfile);
bool sign;
printf("input sign:\n");
scanf("%d",&sign);
if(sign==1)
{
printf("Encrying...");
Encry(infile,outfile);

}
if(sign==0)
{
printf("UnEncrying...");
Unencry(infile,outfile);
printf("out");
}

return 0;
}


你可能感兴趣的:(c,加密,解密,职场,休闲)