Best way to prevent user from accesing data

时间:2015-07-08 15:53:29

标签: java storing-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.

4 个答案:

答案 0 :(得分:2)

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.

答案 1 :(得分:0)

You can encrypt and store the date in a text file.Encryption will prevent the user from modifying it.

答案 2 :(得分:0)

You can use sqlite which is a file-based DB. It supports encryption as well as many operating systems, easy to install and use!

Read more about it here.

答案 3 :(得分:0)

实现此目的的一种非常简单的方法是使用序列化。它允许您直接获取java对象并将其保存为当前状态。一个很好的教程是http://www.mkyong.com/java/how-to-write-an-object-to-file-in-java/

轻松读取和更改此数据的唯一方法是,您可以访问创建它的java类。