帮我看看,这个加密的想法错那了??
给文本加密我想那个数组循环这和每个数异或后存入文件,怎么执行过程那么奇怪。。。
#include <stdio.h>
#include <conio.h>
int mima[3]={15,48,32};
int jiami()
{ int ch,dh,i=-1;
FILE *fp1,*fp2;
fp1=fopen("e:\\as\\ds.txt","rb");
if(fp1==NULL)
printf("can not open the file!!");
fp2=fopen("e:\\as\\jiami.txt","wb");
if(fp2==NULL)
printf("can not open the file!!\n");
ch=fgetc(fp1);
while(!feof(fp1))
{ i=i+1;
dh=ch^(mima[i]);
printf("% d ",mima[i]);
printf("jiami");
if(i==2) //到第三个数时回到第一个数
{i==-1;
}
fputc(dh,fp2);
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
}
int jiemi()
{
int ch,dh,i=-1;
FILE *fp1,*fp2;
fp1=fopen("e:\\as\\jiami.txt","rb");
if(fp1==NULL)
printf("can not open the file!!");
fp2=fopen("e:\\as\\jiemi.txt","wb");
if(fp2==NULL)
printf("\ncan not open the file!!\n");
ch=fgetc(fp1);
while(!feof(fp1))
{ i=i+1;
dh=ch^(mima[i]);
printf("% d ",mima[i]);
printf("jiemi");
if(i==2)
{i==-1;
}
fputc(dh,fp2);
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
}
main()
{ printf("\n");
jiami();
printf("\n");
jiemi();
getch();
}