📄 main.cpp
字号:
#include "rc4.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <time.h>
rc4_key rckey;
unsigned char c;
char key[256];
int i=0;
void encode()
{
FILE *fp1=fopen("c:\\a.log","rb");
FILE *fp2=fopen("c:\\a.txt","wb");
int len=filelength(fileno(fp1));
printf("输入密钥:");
scanf("%s",key);
prepare_key((unsigned char *)key,strlen(key),&rckey);
for(i=0;i<len;i++)
{
c=fgetc(fp1);
rc4(&c, 1, &rckey);
fputc(c,fp2);
}
printf("加密完成!\n");
fclose(fp1);
fclose(fp2);
}
void decode()
{
FILE *fp=fopen("c:\\a.txt","rb");
int len=filelength(fileno(fp));
int n=0;
char timebuf[26];
_strtime_s(timebuf,9);
printf("开始时间:%s\n",timebuf);
while(1)
{
itoa(n,key,10);
printf("\x0dTesting Key:%s",key);
prepare_key((unsigned char *)key,strlen(key),&rckey);
fseek(fp,0,SEEK_SET);
for(i=0;i<len;i++)
{
c=fgetc(fp);
rc4(&c, 1, &rckey);
if (!(c==0x09 || c==0x0a || c==0x0d || (c>=0x20 && c<=0x80)))
break;
}
if (i==len)
break;
n++;
}
printf("\n解密成功!");
_strtime_s(timebuf,9);
printf("结束时间:%s\n",timebuf);
fclose(fp);
}
void main()
{
encode();
//decode();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -