Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What options are there for saving game data in a secure manner? I'm interested in solutions specifically tailored for C++.

I'm looking for something that is fast and easy to use. I'm only concerned about storing simple information such as

  • Which levels are and are not unlocked

  • The user's score for each level

I'm curious again to know what's out there to use, any good libraries to use that give me nice, secure game data files that the average player can't mess with.

I just found this here which looks very nice, but it would be great to get some opinions on potential other libraries/options out there.

share|improve this question
3  
Why do you require the security? If a player wants to cheat to unlock a level by editing the save because they got stuck why not just let them do it? –  Adam Feb 3 '12 at 1:18
1  
well, the game will hopefully go up on IndieCity.com, they have there own achievement system to use. I want to base only a few achievements off defeating certain levels containing bosses. To have the player able to cheat his way to unlocking these achievements isn't allowed. Its against the "CAP" rules as they are called. So i need to have some form of security measure in place, nothing fancy but just to stop the the casual player from altering data –  dan369 Feb 3 '12 at 1:28
    
It might be worth telling IndieCity.com that there are limits to that requirement, as it's impossible for you to secure a save game unless the save game stays on your own server. –  Kylotan Feb 7 '12 at 20:34

4 Answers 4

up vote 17 down vote accepted

first lets say since you have a very simple save file, you can use text file.

one of the simplest ideas is to use a string key to lock/unlock data:

void encrypt(string& data,string key)
{
    for(unsigned i=0;i<data.size();i++)
        data[i] += key[i%key.size()];
}

void decrypt(string& data,string key)
{
    for(unsigned i=0;i<data.size();i++)
        data[i] -= key[i%key.size()];
}

but after a little google search I've found these links, which might be useful:

share|improve this answer
    
this seems like a nice little method :), just enough for my purposes. Im curious to ask a further question here, in terms of a "key", what is an acceptable key? Can i pass in anything i.e a long string? –  dan369 Feb 3 '12 at 1:59
    
And you know, i think im just going to go with this, it's exactly what i wanted. Simple and easy to use, and nothing too fancy :). –  dan369 Feb 3 '12 at 2:12
2  
@Danran yeah every thing is acceptable for the key, it can be a one char string which will result in something like Caesar cipher or any other phrase with any other length you like. you can also use some other algorithm to scramble data positions, eg. swap values in even and odd positions. –  Ali.S Feb 3 '12 at 9:45
    
I suggest you use XOR instead of increment/decrement, as you might end up with corrupt data if you exceed the bounds of the data-type you're dealing with (char I assume) –  bummzack Feb 3 '12 at 15:17
2  
It dons't really matter, either you use xor, or increment/decrements, data recovers. note that if incrementing generaees overflow, later decreament will also generate underflow. –  Ali.S Feb 3 '12 at 15:22

Here are a few programs (free ones anyway) that could help you, they both basically combine all you resources into a single exe.

  • NBinder, now a commercial product, this is an old but functional version.

  • Enigma Virtual Box, another tool with similar features.

share|improve this answer

You can definitely leave your save file unencrypted but add a checksum that is calculated through all the values that you want to "guard".

The cracker would therefore be able to re-produce the hashing (which you off course will use with proper salt) and therefor will have a happy time trying to re-produce.

This would still not be %100 secure but, probably the best time effective solution.

share|improve this answer

Nothing can be considered secure client side; anyone who tells you it is, is lying.

You can use any encryption and scramble method you want, but since the client must be also able to decode it, and the user has access to the client itself, if he is resourceful enough he'll have access to the decryption key / algorithm.

You can only add layers of annoyances to someone willing to crack it, but given enough time it will be cracked, and you can't do anything about that.

share|improve this answer
13  
While what you're saying is true, I think the author is aware that a determined hacker could probably still get at it, since he explicitly asked for a way to prevent "casual hacking". :-\ –  loneboat Feb 3 '12 at 19:27
1  
Exactly, well aware that a hacker if that determined could easily access my game data. I just didn't want the average/casual user to be able just to simple open up the files and start editing them. –  dan369 Feb 4 '12 at 1:54
    
@Danran: fine, I don't like that very much but I guess it makes sense in some contexts. I'm not deleting the answer because I think it is important to point this out to people reading this. –  Lohoris Feb 4 '12 at 13:04
1  
Also, if it's deemed worth hacking someone will likely make it so that hacking it is possible by the casual user. There are entire forums dedicated to just that. –  Noctrine Feb 7 '12 at 19:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.