infile.txt
来自「<<inter 汇编程序设计>>的源代码」· 文本 代码 · 共 61 行
TXT
61 行
INFILE.TXT
This text file will be encoded by the Encode.exe program:
#include <iostream.h>
#include <fstream.h>
/* Translate a buffer of <count> bytes, using an encryption
character <eChar>. Uses an XOR operation (ASM function).*/
//extern "C" void TranslateBuffer(char *buf,
// unsigned int count, char eChar);
void TranslateBuffer( char * buf, unsigned count, char eChar )
{
__asm
{
mov esi,buf // necessary to push ESI?
mov ecx,count
mov al,eChar
L1:
xor [esi],al
inc esi
Loop L1
}
}
const int BUFSIZE = 200;
char buffer[BUFSIZE];
int main()
{
unsigned int count; // character count
// character used for encryption
const unsigned char encryptChar = 241;
char infilename[] = "infile.txt";
char outfilename[] = "outfile.txt";
ifstream infile( infilename, ios::binary );
ofstream outfile( outfilename, ios::binary );
while (!infile.eof() )
{
infile.read(buffer, BUFSIZE );
count = infile.gcount();
TranslateBuffer(buffer, count, encryptChar);
//outfile.write(buffer, count);
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?