// Z3SCrypt.cpp : ÄÜ¼Ö ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇÑ ÁøÀÔÁ¡À» Á¤ÀÇÇÕ´Ï´Ù. // #include "stdafx.h" #include #include #include using namespace std; char * enckey = "cjsgkdmlTlqkfshaemfdmlwktlsdjqtsmsgkfn"; void Encrypt(char * filein, char * fileout) { // óÀ½ 256¹ÙÀÌÆ®´Â Çì´õ ifstream in (filein, ios::in|ios::binary); DeleteFileA(fileout); ofstream out (fileout, ios::out|ios::app|ios::binary); if ( (in.is_open()) && (out.is_open()) ){ char a; int counter = 0; for(int i = 0; i < 256; ++i) { in.get(a); out.put(a); } while (in.get(a)) { if (counter == ((sizeof(enckey) / sizeof(char)) - 1)) { counter = 0; } a = ((a ^ enckey[counter]) + counter); out.put(a); counter++; } } else { printf("Could not open input or output file."); } in.close(); out.close(); printf("Done.\n"); system("pause"); } void Decrypt(char * filein, char * fileout) { // óÀ½ 256¹ÙÀÌÆ®´Â Çì´õ ifstream in (filein, ios::in|ios::binary); DeleteFileA(fileout); ofstream out (fileout, ios::out|ios::app|ios::binary); if ( (in.is_open()) && (out.is_open()) ) { char a; int counter = 0; for(int i = 0; i < 256; ++i) { in.get(a); out.put(a); } while (in.get(a)) { if (counter == ((sizeof(enckey) / sizeof(char)) - 1)) { counter = 0; } a = ((a - counter) ^ enckey[counter]); out.put(a); counter++; } } else { printf("Could not open input or output file."); } in.close(); out.close(); printf("Done.\n"); system("pause"); } int main(int argc, char* argv[]) { printf("ROW Z3S Crypt v1.0\n\n"); if(argc < 4) { printf("z3scrypt.exe cryptname inputfile outputfile\n\n"); printf("ex) z3scrypt.exe encrypt zone1.z3s zone1.cry\n\n"); return 0; } if(_stricmp(argv[1], "encrypt") == 0) { Encrypt(argv[2], argv[3]); } else if(_stricmp(argv[1], "decrypt") == 0) { Decrypt(argv[2], argv[3]); } else { printf("No such option.\n\n"); } printf("done.\n\n"); return 0; }