Search code examples
javastoring-data

Best way to prevent user from accesing data


So, I've been practicing game development in java. Now I'm trying to save user's progress by putting data in a file. But if I put it just into a text file, obviously it's going to be easily accessible. What would be the best way to store/hash data like for example "current level, attack power etc".

Thanks.


Solution

  • It is going to be a vague answer.

    If you simply just don't want it to be a text file, you can write a binary file using binary serialization of the language you are using.

    As a second step, you may consider encrypting your files.

    But, no matter what you do, or how hard you try, as long as all the data are stored on the client then your users may still be able to alter them.

    If you don't want to store all the info remotely due to space constraints, you can store just the file hash remotely and verify that it has not been tampered with.