Simple hiscore encryption

Hiscores are nothing fancy, but I really need to be able to persist them between games, othewise they’re not much use. How have others done this?

My first thought would be to write the output as text ('cos then its nice and easy to parse) and encrypt it somehow, but I’m not sure if theres any built-in encryption that I can lay my hands on.

Second thought would be to stick the text into a zip file and stick a password on the zip, but I can’t see any functionality for using passwords on zip files :frowning:

Lastly (and weakest) would be just to write the output as binary and hope people can’t really be bothered looking at it closely…

If you just serialize it as normal Java serialized data no-one’s going to look at it.

Cas :slight_smile:

At work, I use persistence scheme which serialized objects to database and after a year I’m able to recognize a lot of info by just looking at binary dump :wink:

Easiest IMHO would be to gzip stream and then just do something so header will not be recognized - prepend it with few bytes, or xor entire stream with some arbitrary algorithmic serie. Compression is good enough to scare away any people looking for localized changes for specific field differences. Just make sure that they are not automatically opened in Total Commander :slight_smile:

…and any obfuscation you add is irrelevant the moment someone decompiles the source.

If it’s important that no one alters the saved data, you wouldn’t be writing the app in Java and wouldn’t be running it on the client. Go for something simple that takes no time to implement, and just ignore those who try to mess with things.

Yeah, and make the highscore only list last few days entries so that cheaters will have to do it every week (in which case you can identify and hopefully ban them)

If you feel like it, use javax.crypto. Quite simple to use, I can show you an example if you want.

Or, you can amuse yourself by inventing your own encryption scheme. Combine Caesar with some other simple algorithms, and it’ll be kinda hard to break.

If people can decompile your bytecode, however, it’s a different story. :frowning:

imo, unless there are prizes to be won, i would just zip it, or not even bother. i remember editing the hiscore file in minesweeper a few years back (they prevent that now), and so what if my time was amazing or whatever…

seing as the hiscore would be on the client in your case, i guess there aren’t giveaways involved, so let the nuts out there have their hollow bragging rights.