Advertisement

Best way to hide a file from the user ?

Started by November 03, 2014 06:16 PM
8 comments, last by Drusselnahg 10 years, 2 months ago

Hello,

I am programming a game and I was wondering what are the best ways to hide a file from the user so that he can't modify it and cheat. For example, how to hide the .txt file that saves all the player's stats. I am not prepared to use an online database to store all the data.

Thanks.

If you're talking about a desktop game, a simple way is to just rename the file to *.dll or *.so or some other regular file, like button_press.wav, To this, you could add simple XOR encryption so even if they try to open the file with a text editor it won't seem text data.

http://en.wikipedia.org/wiki/XOR_cipher

If this is a javascript app or something else then some more details would be helpful.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Advertisement

The problem with changing the extension to .dll or something else is that you can still open it and read it by doing: right click > open with > bloc-notes. I guess encryption would be a good solution, but I would still quite like to know if there are other solutions. Thank you for your answer.

You won't stop anyone who knows what they are doing with a simple hiding approach.

You can obscure the data, hide it somewhere, but you'll ultimately only be wasting your time. Someone who wants to solve it will figure it out then post the solution online.

For a game run entirely on the player's computer you shouldn't really bother trying to stop cheating. On a single player or local experience let them cheat as much as they want.

Don't spend your valuable time trying to stop the users from experimenting. Spend your time creating features that add value and increase your sales.

You could just write the file in binary mode. Then people that do not know it's structure will usually have a harder time messing it up. (example first 12 bytes 3 ints for hp, ap, ad, then a char for name etc.) - if you open that file with a normal text editor you'll see some gibberish.

@frob: Yes, I guess that you are right.

Thank you everybody for your answers.

Advertisement

There is a long lost "art" called "file batching" .

Back in the day developers use this method to hide all their resource files behind their .exe .

How to batch files in Windows DOS: [LINK 1] [LINK 2]

First thing is to create a file directly on you C drive, and name it something that is easy to remember. "AAA" will work.
Second thing is to make a copy of your picture, and place it in that folder. I will assume the picture is named "Picture.jpg".
Third thing you will need is a file to batch with it. Make a copy of it, and place it in your folder ( AAA ). I will assume the file is named "File.xyz"
Forth thing is to find, and open DOS prompt. Change the directory to your folder ( AAA ) . To do this type in "cd C:\AAA". Next type in " copy /b Picture.jpg+File.xyz NewPicture.jpg ".
The picture file must come first, and the other files after.

Don't bother Googling "file batching" - this is a very old technique, and you will end up with nothing but trash results.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

I don't believe it was mentioned anywhere here, but for the Uber simple don't show in Finder or Explorer approach, just start your file name with a period. This of course is easy to circumvent ( you just turn on show hidden files ), but for the majority of users it should be enough.

I don't believe it was mentioned anywhere here, but for the Uber simple don't show in Finder or Explorer approach, just start your file name with a period. This of course is easy to circumvent ( you just turn on show hidden files ), but for the majority of users it should be enough.


This only works on Mac or Linux - Windows hidden status is determined by a file flag, not the name.
I'm guessing your file is a resource. Like parameters or map or whatever.
Just package it.
Inside a archive. Create your own format or use password protected zip.
Decpress it in memory.

A cheater will still able to reverse your game and find the code but not that easy. Especially if you compute the code for example with the game version number .


If you can't pack your file, just sign it. ( make a hash of it like md5 and compare that to a known result).

This topic is closed to new replies.

Advertisement