#include <iostream>#include<fstream>using namespacestd;intMainintargcChar*argv[]) { if(ARGC <3) {cout<<"usage:project infile outfile"<<Endl; return-1; } Const intBUFSIZE = -; CharBuf[bufsize]; unsignedintCount//Char CountUnsignedintEncryptmask; cout<<"encryption code[0-255]?"; CIN>>Encryptmask; if(encryptmask<0|| Encryptmask >255) {cout<<"between 0 and 255."<<Endl; return-1; } unsignedCharEncryptcode = (unsignedChar) Encryptmask; Ifstream infile (argv[1],ios::binary); Ofstream outfile (argv[2],ios::binary); cout<<"Reading"<<argv[1]<<"and createing"<<argv[2]<<Endl; while(!infile.eof ()) {Infile.read (buf,bufsize); Count=Infile.gcount (); if(count==0) Break; __asm{Lea ESI, buf mov ecx,count mov al,encryptcodel1:xor [esi],al inc ESI Loop L1} outfile.write (Buf,count); } infile.close (); Outfile.close (); return 0;}
C + + inline assembler code, simple file encryption