Advertisement

Compress data

Started by April 07, 2011 07:33 AM
0 comments, last by SiCrane 13 years, 7 months ago
So i am using SDL and I want to be able to compress all data into one file. I want to do this to stop people from editing the file and I want the game to still be able to access the data.
The data would include pictures and a font.
Short answer: forget it.

Slightly longer answer: Use a standard compression scheme and run a cheap encryption (xor, or rot13 or some other trivial algorithm) over it, so standard packers won't recognize it. Add a CRC to it, if you want.

Even longer answer: It is futile to try and prevent people from reading or even editing what's on their computer, it just won't work. If your program can read the data, then no matter what encryption you use, the decryption key and algorithm must be on the computer, so someone can access your data. You can prevent casual editing, but you cannot prevent someone who is determined to do it. Your time is better spent elsewhere.
Advertisement
In particular you can use a standard zip file (which can be renamed to a different extension if you want) and read it with a library like physfs, which interfaces cleanly with the most commonly used SDL libraries.

This topic is closed to new replies.

Advertisement