- Home /
How to protect JSON file game data?
Hi, I'm working an RPG game which have the data for various monster types and I considered using JSON to store the data. I've watch this tutorial https://unity3d.com/learn/tutorials/topics/scripting/game-data-editor-gui?playlist=17117
However, I found (10.54 in the video above) that it is so easy to change the JSON file from StreamingAssets folder in Unity. So, my question is how can I make JSON file safe from being edited?
I know that the determined hackers can finally hack my game anyway but I don't want it to be as easily as shown in the tutorial video above. I've searched for around the web many hours but not found a single solution other than put JSON file on the server. If you have any other alternative solution, I'm glad to hear it as well :)
Answer by UnityCoach · May 01, 2017 at 09:04 PM
The whole point of using JSon/xml etc, is to make files editable elsewhere. You can use binary otherwise.
Thank you for your reply. I will try to implement the binary.
I wouldn't use Binary if you plan to export to Window Store. I've got a problem now where using System.Runtime.Serialization.Formatters.Binary; isn't supported on that platform, so now I have to redo my whole game save system.
https://forum.unity.com/threads/uwp-build-error-namespace-formatters-does-not-exist.422308/
http://answers.unity3d.com/questions/870958/need-help-regarding-systemruntimeserializationform.html
i would recomand to use SharpSerializer ins$$anonymous$$d, it's a great library that allows to serialize to binary and json even on platforms that doesn't have system.runtime.serialization.formatters
Answer by BodhiPurplePill · May 01, 2017 at 02:07 PM
Use persistent datapath instead of streamingassets (a little more hidden location to save your file)
A json is a string, you could swap some characters with a keyword like here: http://stackoverflow.com/questions/23780833/c-sharp-very-simple-string-encryption-for-game
You could also do the same for the bytes in the file.
You could use a long keyword for this or (for example) the device's unique id (to avoid copying saves)
Thank you for your reply. I think it may suit with my game!
Answer by Shugabush · Jan 19 at 12:47 AM
I think if you edit the json file data in windows explorer, it won't actually change the data (at least on the build).