This question is difficult to answer authoritatively, because without equipment protected from unauthorized access, it is almost impossible to protect content from a complex hacker. But given the clarification that a simple deterrent is good enough, how about embedding your content as resources in an executable ? Note that the tools available for extracting resources from .exe files are available.
Alternatively, you can encrypt each file and decrypt it when your application downloads it. Encryption can be as simple as xor-ing each byte with a known constant byte, or you can use a real encryption algorithm like one from Microsoft CryptoAPI . Using a real algorithm will improve obfuscation, but still will not be really safe.
Here's a simple program that uses this RC4 implementation (which is easier to use than CryptoAPI) to encrypt or decrypt a file and write its toddout:
#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 into a 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 the key from a 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 to stdout. std::cout.write(&buffer[0], buffer.size()); return 0; }
Please note that this is not a safe way to use RC4, and the RC4 algorithm itself is no longer considered safe.
source share