c++ - How to encode external files that come with the .exe -


so made application visual 2012 loades images , shaders (plain text). really, don't want people open images , shaders , mess around. how can compress external files single or multiple files still readable executable?

this question difficult answer authoritatively because without tamper-proof hardware impossible secure content against sophisticated hacker. given clarification simple deterrent enough, how embedding content resources in executable? note there tools freely available extract resources .exe files.

alternatively encrypt each file , decrypt when application loads it. encryption simple xor-ing each byte known constant byte or use real encryption algorithm 1 microsoft cryptoapi. using real algorithm improve obfuscation still won't secure.

here's simple program uses this rc4 implementation (which easier use cryptoapi) encrypt or decrypt file , write stdout:

#include <algorithm> #include <iostream> #include <fstream> #include <iterator> #include <vector>  // insert rc4 implementation here  int main(int argc, char *argv[]) {    const std::string password = "no more secrets";    const std::string filename = argv[1];     // read file buffer.    std::ifstream f(filename.c_str(), std::ios::in | std::ios::binary);    std::vector<char> buffer;    f >> std::noskipws;    std::copy(       std::istream_iterator<char>(f), std::istream_iterator<char>(),       std::back_inserter(buffer));     // initialize key password.    rc4_key key;    prepare_key((unsigned char *)password.data(), (int)password.size(), &key);     // encrypt or decrypt (same operation).    rc4((unsigned char *)&buffer[0], (int)buffer.size(), &key);     // write result stdout.    std::cout.write(&buffer[0], buffer.size());     return 0; } 

note not secure way use rc4 , rc4 algorithm no longer considered secure.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -