Save-Manager
A class for managing encrypted storage data.
Set-Encryption-Key
Set the encryption key for the SaveManager.
Arguments:
encryption_key (bytes): New encryption key to be set.
Generate-Encryption-Key
Generate a new encryption key using Fernet.
Returns:
bytes: Generated encryption key.
Set-Save-Path
Set the save path for the SaveManager.
Arguments:
path (str): New path to be set for saving data.
Save
Save data to the file using a specified key-value pair.
Arguments:
key: Key for the data.
value: Value to be saved corresponding to the key.
Returns:
bool: True if saving is successful, False otherwise.
Load
Load data from the file using the specified key.
Arguments:
key: Key to retrieve data.
default: If key is not found, default will be returned instead.
Returns:
any: Retrieved value corresponding to the key, or default value if not found.
Backup
Create a backup of the current save file.
Args:
backup_path (str): Path to store the backup file. Defaults to "data/saves/backup".
Examples
Encryption Key
key = self.savemanager.generate_encryption_key() #Generating Key
self.savemanager.set_encryption_key(key) # Set Key for Encryption
Save
self.savemanager.save('playerpos',[0,0])
Load
print(self.savemanager.load('playerpos'))
>>>[0,0]
Backup
self.savemanager.backup()
📁game_name
📁data
📁saves
📁backup
📃save-01.10.2023 10-00-00 # your backup file with timestamp
Last updated
Was this helpful?