Encrypt binary files?

This is kind of dumb, but I’m thinking I want to try and do my own encryption of my binary save files.

I’m sure there’s a lot of really good reasons why this is a bad idea, but my thinking is that there’s going to be a plethora of off the shelf encryption methods out there and anyone who is dead set on cracking them will be familiar with the tools that already exist which is in itself a weakness.

Also it sounds like a fun thing to try.

So my thinking is that I would make an encryption seed based on something that would be specific to each install, then every time I make a key run the seed through a method that scrambles it based on that seed, and do it in reverse each time I load the file.

Does that make sense?

Your time is yours to spend. Just be sure you understand the futility of this endeavor.

If you’re concerned about the user ‘hacking your save files,’ or ‘cheating in your game,’ which is playing on their computer, just don’t be.

There’s nothing you can do about it. Nothing is secure, it is not your computer, it is the user’s computer.

If it must be secure, store it on your own server and have the user connect to download it.

Anything else is a waste of your time and the only person you’re going to inconvenience is yourself when you’re debugging the game and you have savegame errors. Work on your game instead.

Remember, it only takes one 12-year-old in Finland to write a script to read/write your game files and everybody else can now use that script. Read about Cheat Engine to see more ways you cannot possibly control this.

1 Like

No one like a single player game dev that makes their save files hard to alter.

A vast majority of players aren’t going to bother anyway.

There’s merit in your save files being editable too.

Yeah, I’m procrastinating.

I am concerned that I will have a scoreboard that will be easily compromised, but it’s a fruitless endeavor I suppose.

One of the themes of my game is I want it to have a dynamic difficulty that ensures people die every once in a while, but then tallies up the difficulty level you reached the end with and divide it by the completion time.

It will have save rooms and every time you reach a new save room it adds the current difficulty level (1-10). If you die once it goes up one level. If you die again it goes down by 2. Then down by 1 every additional death.

When you reach a new save room it goes up by 1 if you haven’t died, 2 of you get there with no damage, -1 or you have died once, and 0 of you died more than once.

Then at the end of the game it adds up the difficulty levels of the same rooms, gives you +1 for each item found, and then divide by the game time to get the final score.

And of course have an endgame plus where it starts you at 10 and another where it locks in a difficulty level.

So this is some stuff I clearly don’t want a hacker to mess with so people can post their rankings.

If you are worried about results posted to scoreboard then people messing with savefiles might not be your biggest worry. Even if you are saves were fully protected it is very common for hackers to just target the network API that you use for submitting score. In the default case it doesn’t take much effort find out the URL game uses for submitting score and the request format, sometimes it might be even simpler than messing with rest of the game. So the best thing to do might be investing time in improving moderation tools so that you can efficiently remove and identify blatantly fake score submissions from leaderboard. A lot of time cheaters will try to submit scores better than any real player(because what’s the point of cheating if you don’t get on top), but if they are submitting average scores there is little harm for rest of the players (unless they contain spam) so little need to identify and remove them.

1 Like

Exactly this… hackers don’t play by rules. @Not_Sure keep in mind that encrypting save files is like putting an enormous sharp stake right in the middle of your garden to keep people out of your house. Some people will see it and keep away.

But a determined hacker will see the spike and walk around the back and break a window and get in. Or if there are no windows he’ll sledgehammer your wall in. Or he’ll tunnel into your basement and up into your living room.

You cannot stop hackers. It’s what they do.