64,647
社区成员
发帖
与我相关
我的任务
分享
if (fseek(fi,-2,SEEK_CUR)) break;
[/quote]
这是从文件尾到文件头进行异或进行加密吧。if (fseek(fi,-2,SEEK_CUR)) break;
#ifdef MSG_EXPORTS
#define MSG_API __declspec(dllexport)
#else
#define MSG_API __declspec(dllimport)
#endif
class MSG_API MSG_ENCRYPT
{
public:
MSG_ENCRYPT(void);
~MSG_ENCRYPT(void);
void Encrytion(unsigned char * pdata, unsigned char * pkey, size_t Size,size_t KeySize);
void Decrypt(unsigned char * pdata, unsigned char * pkey, size_t Size,size_t KeySize);
private:
static const int Encrypt[256];
static const int Deciphering[256];
};
#include <stdio.h>
#include <string.h>
#include <conio.h>
FILE *fi,*fo;
int i;
int main(int argc,char **argv) {
if (argc<3) {
printf("Usage:%s src des\n",argv[0]);
return 1;
}
if (0==stricmp(argv[1],argv[2])) {
printf("Src and des is same!\n");
return 2;
}
fo=fopen(argv[2],"wb");
if (NULL==fo) {
printf("Can not create file %s\n",argv[2]);
return 3;
}
fi=fopen(argv[1],"rb");
if (NULL==fi) {
fclose(fo);
printf("Can not find file %s\n",argv[1]);
return 4;
}
i=0;
fseek(fi,-1L,SEEK_END);
while (1) {
fputc(fgetc(fi)^0x5A,fo);
i++;
if (i%1000000==0) cprintf("\r%dKB",i/1000);
if (fseek(fi,-2,SEEK_CUR)) break;
}
fclose(fi);
fclose(fo);
cprintf("\r%dKB OK.\r\n",i/1000);
return 0;
}
fputc(fgetc(fi)^key[i++],fo);