JavaMan111
JavaMan111

Reputation: 35

Making an uneditable gamesave file

What I am doing is making a console blackjack for fun. I want to save the money so users can play day by day but I don't want to save it in a text file where the user can easily change the amount as they please.

I already thought of making a hidden file or a encrypted file with a password but I don't like that. I want it to be sort of like when you open some random dll file, all you see is gibberish that you can't understand.

Upvotes: 1

Views: 344

Answers (4)

9000
9000

Reputation: 40884

A bulletproof way to prevent users from tampering with their stats is to store stats away from them, on a remote server. This will require users to be online during play, though. OTOH you'd be able to show a ladder of top players and so on.

An encrypted file is probably the best route if you want offline storage. You just need to hide the file properly.

Before modifying the file, read its modification time. After the update, restore the time. The user will have harder time figuring out which file has changed.

Use an innocent file used by your game with a data block inside allowed by format. It could be an XML file storing the encrypted string in a comment. It could be a JPG or PNG file storing the encrypted string in a comment or EXIF section, at a known offset (so you don't need to parse the file). WAV, OGG, MP3 also allow inclusion of non-interpreted data. This is not real steganography when you hide your data inside the actual pixel values and such, and is far easier.

I suppose you understand that a determined cracker with a disassembler and a debugger can crack this scheme. But an average user probably won't bother.

Upvotes: 2

user845279
user845279

Reputation: 2804

You can get the effect of having a file that contains gibberish using encryption. Just save the encrypted data as bytes (not converted to ASCII representation). Since the encrypted data can have values between 0x00 and 0xFF, there will be gibberish.

Here is a simple example of how to encrypt text: http://www.exampledepot.com/egs/javax.crypto/desstring.html

Upvotes: 1

1321941
1321941

Reputation: 2170

You can encrypt the values within the file: Have a look at: http://dinofilias.com/encrypt.htm With basic encryption like this as long as the user does not have access to the key, your data is relatively secure.

Upvotes: 1

Oleksi
Oleksi

Reputation: 13097

It sounds like you are talking about Steganography, but traditional encryption is probably safer and easier to implement.

Upvotes: 1

Related Questions