- Home /
Saving important data securely
Hey guys,
I am in the process of making a game that allows users to create their own weapons, and have ran into what might be an issue. When the player creates their weapon I want it to be saved to their "Armory" which is just a script that holds all of their weapons. Now the problem I am facing is how to actually save this and it not be tinkerable by the user, as this would potentially create an imbalanced game if someone adjusted the damage of the weapon in the save.
Also any suggestions on how to go about saving this will be greatly appreciated.
There is a paid course you can get for FREE on Udemy. It covers 5 different methods to save and load data in Unity3D. It covers PlayerPrefs, Text files, Binary Serialization, Xml Serialization and even SQLite! The free coupon link for this course is https://www.udemy.com/saving-and-loading-game-data-in-unity3d/?couponCode=UNITY Goodluck!
Answer by DuxDucis · Dec 19, 2012 at 11:30 PM
You could use the fairly easy serializer JSON.NET to serialize the class in which you weapon variables are stored. That will leave you with a string which can be encrypted, click here for further info on encryption http://stackoverflow.com/questions/10168240/encrypting-decrypting-a-string-in-c-sharp. And then just commonly save to a plain text file and unencrypt and deserialize with JSON.NET at load. If you post some code I can give you an example.
Note that if this is a multiplayer game and you are worried about cheating then the only way to secure such data is to store it on the server. Any local file can be hacked by the diligent hacker. You are then getting into the realm of authoritative servers.
Answer by UnityDeveloper08 · Dec 20, 2012 at 12:11 AM
Thanks for the help Dux. How easy would it be for someone to hack this and create their gun too powerful or to put an upgrade on it that should be locked? Sorry that I dont have any code atm as it is all in R&D atm and is very sloppy.
You don't have to worry about someone unencrypting that as the key you use to encrypt is unique.
It isn't as hard as you may thing actually. Remember that the key will be stored locally. You don't have to crack it, you just need to find the key. If its a single player game though, then none of this is needed at all. Only multiplayer games need this type of security.
The game is infact multiplayer. I think the best bet would be the authorative server route, although I have no clue where to begin with that. Anyone have any advice on it?
use a 256 bit encryption and hackers will need a super computer to crack it. well, you cant really crack encryption, you can just brute force it by trying every password combination possible and it would take years
Your answer
Follow this Question
Related Questions
How to create an XML file in Unity 1 Answer
Save data through xml Serialization on iOS 1 Answer
saving data 1 Answer
whats the best way to save a large list of variables? 1 Answer
Saving/Loading Vertices Efficiently 2 Answers