Summary Json 5 Saving Strategies · Wiki · Brian K. Trotter / RPGMods · GitLab gitlab.com
1,378 words - html page - View html page
One Line
Json is a commonly used, but insecure, data transfer format that can be made secure for save files by implementing a saving system with the strategy pattern and discussing encryption methods in the next post.
Slides
Slide Presentation (7 slides)
Key Points
- Json is a highly portable format for transferring data that is device and language independent.
- Json files are human-readable and editable, making them insecure for a published game.
- The strategy pattern can be used to switch between different encoding methods for saving files.
- The SavingStrategy class is an abstract class that manages the reading and writing of save files.
- The JsonSavingSystem class uses the SavingStrategy to perform file operations.
- The JsonStrategy is a specific implementation of the SavingStrategy that saves and loads data in JSON format.
- The JsonStrategy can be assigned to the JsonSavingSystem to enable saving and loading of JSON files.
- Encryption methods can be implemented to make save files more secure and harder to read.
Summaries
36 word summary
Json is often used for data transfer but can be insecure for save files. A saving system can switch to a secure setup using the strategy pattern. Encryption methods will be discussed in the next post.
81 word summary
Json is commonly used for data transfer but poses security risks for save files. To address this, a saving system can switch to a more secure setup for production builds using the strategy pattern. The SavingStrategy.cs class manages reading and writing save files. The JsonSavingSystem class is modified to integrate the strategy pattern, with methods like LoadJsonFromFile and SaveFileAsJson. A JsonStrategy class is introduced as an example. Encryption methods will be discussed in the next post for enhanced save file security.
119 word summary
Json is a popular format for data transfer, but it poses security risks for save files due to its human readability and editability. To address this, a saving system can be set up to use Json during development and switch to a more secure setup for production builds. The strategy pattern is used to implement this solution. The SavingStrategy.cs class serves as the base for real strategies, managing the reading and writing of save files. The JsonSavingSystem class is modified to integrate the strategy pattern, with methods like LoadJsonFromFile and SaveFileAsJson calling the appropriate strategy methods. A JsonStrategy class is introduced as an example strategy. In the next post, encryption methods will be discussed to enhance save file security.
241 word summary
Json is a great format for transferring data, but it has a problem when it comes to save files. Unlike BinaryFormatter, Json files are human readable and editable, making them insecure for published games. To address this issue, the saving system can be set up to use Json during development and then switch to a more secure setup for production builds. The strategy pattern is used to achieve this.
The SavingStrategy.cs class is an abstract class that serves as the base for real strategies. It manages the reading and writing of save files based on the data collected by Capture and Restore methods. The abstract methods in this class are overridden in the real strategies to perform the actual file operations.
The JsonSavingSystem class undergoes some changes to integrate the strategy pattern. The LoadJsonFromFile and SaveFileAsJson methods are modified to call the appropriate methods in the SavingStrategy. ListSaves method now compares the file extension with the one provided by the strategy. GetPathFromSaveFile method is also changed to return the Strategy's GetPathFromSaveFile. The rest of the saving system remains unchanged.
A JsonStrategy class is introduced as an example of a saving strategy. It includes the save and load methods that were discussed earlier in the post. This strategy can be assigned to the JsonSavingSystem in the PersistentObjectsPrefab.
In the next post, encryption methods will be discussed to make save files more secure. This will provide a foundation for writing custom encryption methods.