#include<stdio.h>
int addkey();
int displaykey();
main()
{
printf("—加密文件--\n");
if(addkey())
printf("加密失败....");
printf("\n\n\n—解密文件--\n");
if(displaykey())
printf("解密失败....");
}
int addkey()
{
FILE *fp,*fpp;
char ch,w[100];
int i=0;
if((fp=fopen("","r"))==NULL)
return -1;
if((fpp=fopen("","w"))==NULL)
return -1;
while(1)
{
ch=fgetc(fp);
ch=200-ch;
i++;
if(!feof(fp))
fputc(ch,fpp);
else
break;
}
rewind(fp);
printf("\n加密次数为%d",i);
printf("\n加密原文件为:");
fgets(w,99,fp);
printf("%s\n",w);
fclose(fp);
fclose(fpp);
printf("\n>>>恭喜您,加密成功--");
return 0;
}
int displaykey()
{
FILE *fp,*fpp;
char ch,w[100];
int i=0;
if((fp=fopen("","r"))==NULL)
return -1;
if((fpp=fopen("","w"))==NULL)
return -1;
while(1)
{
ch=fgetc(fp);
ch=200-ch;
i++;
if(!feof(fp))
fputc(ch,fpp);
else
break;
}
rewind(fp);
printf("\n加密源文件为%d",i);
printf("\n解密源文件为:");
printf怎么加endl fgets(w,99,fp);
printf("%s\n",w);
fclose(fp);
fclose(fpp);
return 0;
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论