무 작위 암호 화 프로그램의 실현 방법
c=a^b
c^b=a
#include "stdio.h"
#include "stdlib.h"
void main(int argc,char *argv[])
{
FILE *fp1,*fp2;
char c,ch;
long j;
if(3!=argc)
{
printf("Command error/n");
exit(1);
}
if((fp1=fopen(argv[1],"rb"))==NULL)
{
printf("Can not open the source file/n");
exit(1);
}
if(NULL==(fp2=fopen(argv[2],"wb")))
{
printf("Can not open the aim file/n");
exit(1);
}
printf("Please input the password:/n");
scanf("%i",&j);
srand(j);
ch=fgetc(fp1);
while(!feof(fp1))
{
c=rand();
ch=ch^c;
fputc(ch,fp2);
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
}