Sign in to follow this  

Hiding Game Data

This topic is 3460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Something that I've wondered throughout developing several projects of my own; how can I hide XML data and/or other game resources once I've finished a game and released the exe? Usually game data and resources are placed in the folder with the exe as normal, but I want to hide all the XML files that I use to data drive my game from anyone once it's released; are there any ways to do this, like convert it to another format that only I can decypher etc? I suppose the obvious solution would be to assign the data to variables inside of constructors once I've tweaked the game through XML files and I'm happy with it but would rather avoid that all together...feel like I would be undoing the time taken to make the game data driven in the first place. I've seen file extensions when downloading freeware off the net with strange extensions that even notepad/ultraedit can't make heads of tails of... Cheers DB

Share this post


Link to post
Share on other sites
This is generally a waste of time, as nothing will stop anybody who really wants to modify the data from doing so -- why do you care, anyway?

Generally simply packing the data up in a simple binary pack format you invent is enough to discourage the casual spelunker, but it won't stop anybody who cares.

[Edited by - jpetrie on June 24, 2008 8:43:15 PM]

Share this post


Link to post
Share on other sites
If someone really wants to access the data then they'll do so no matter what, so don't waste too much effort on it. Easy access for modding can also be an excellent selling point for some games, and there are whole communities centred around doing so.


Now, with the disclaimer out of the way, the general simple, reasonably effective but not particularly secure method is to just pack them into some sort of custom binary format that the casual user won't understand and off-the-shelf products won't be able to open. If you really want to discourage investigation you could also apply some basic encryption, but -- just to reiterate -- don't waste too much effort on this, if someone wants to access and/or change those files they will do so.

Share this post


Link to post
Share on other sites
I wouldn't say it's a waste of time to encrypt your game files. However don't be fooled into thinking they are hack proof. I would agree with jbadams that if someone really wants your data, they will get it in the end.

But isn't this just like anything else? If someone really wants your car stero, they will just smash in your window and steal it right? If someone really wants your brand huge plasma TV you have been showing off in your window, they will break into your house and take it.

With that in mind, reducing opportunity plays a MAJOR role in prevention. Lock your car and home doors, and with basic encryption being somewhat easy to implement, it wouldn't hurt.

Here is a simple start:

convert your data to bits.
for each bit, convert it to the ascii code.
do something to this code (ie +10)
convert it back to chars.
save your data to your file.

Now when you load it into your game, you have to do the reverse and then -10 when it is in ascii code format.

There is a really good tutorial on this site for data encryption. They explain how to generate a 128bit key for encryption.

Share this post


Link to post
Share on other sites
no need to do anything like that.
just put it in a zip file and put a password on it.

or use some algorithm.

http://www.codeproject.com/KB/mcpp/EncDecExt.aspx
there are many more out there

just note that the more you do to the files the longer it will take to process them

Share this post


Link to post
Share on other sites
The only reason for packing and compressing the files is if you are not CPU bound. Then compression can speed up loading, since the decompression will use more CPU and much less I/O.
Otherwise, just use plain packing with a zip-like algorithm or your own.
Just be aware of the fact that most public packing-methods are optimized for I/O and processing, so yours might not (and probably will not) be as effective as the rest.

EDIT: Replaced "encryption" with "compression". I apologize for this stupid typo from my behalf.

[Edited by - nife87 on June 25, 2008 6:45:01 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by nife87
The only reason for packing and encrypting the files is if you are not CPU bound. Then encryption can speed up loading, since the decryption will use more CPU and much less I/O.

No, this is entirely wrong. Encryption does not in any way help reduce I/O, it only serves to increase CPU usage (and of course, hide your data).

Compressing your files may reduce I/O though, but I doubt it will be a noticeable difference. Configuration files are usually small and images and sounds are usually compressed already.

Share this post


Link to post
Share on other sites
Quote:
Original post by nife87
Then encryption can speed up loading.
Encryption will not speed up loading. Compression might, and if you're doing that as well you may in some situations see a speed increase, but just encrypting the data will never speed things up for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by Splinter of Chaos
An alternative might be to validate your files when you load them; check that they haven't been altered and if they have, request that the user re-install.
Note however that this is still quite trivial for a determined player with the appropriate knowledge to circumvent.

Share this post


Link to post
Share on other sites
Thanks for your replies guys :) It's not something I'm that bothered about when it comes to hiding game data; I was just curious and I knew it wasn't a massive deal but would be something I would do for clarity if I had time and could be arsed lol :)

Share this post


Link to post
Share on other sites

This topic is 3460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this