public static async Task LoadAllProfilesAsync(string path) { // This is the encrypted input from the file byte[] soupBackIn = await AsyncHelperExtensions.ReadBytesAsync(path); // Decrypting process Rijndael crypto = new Rijndael(); string jsonFromFile = crypto.Decrypt(soupBackIn, JsonEncryptedKeyProfiles); ProfilesListWrapper profiles = JsonUtility.FromJson <ProfilesListWrapper>(jsonFromFile); SaveManager.profiles = profiles == null ? new List <ProfilesData>() : profiles.Profiles; SaveManagerEvents.current.AllProfilesLoaded(SaveManager.profiles); }
public static async Task SaveAllProfilesAsync(string path) { ProfilesListWrapper profiles = new ProfilesListWrapper() { Profiles = SaveManager.profiles }; string json = JsonUtility.ToJson(profiles); // Encrypting process Rijndael crypto = new Rijndael(); byte[] soup = crypto.Encrypt(json, JsonEncryptedKeyProfiles); await AsyncHelperExtensions.WriteBytesAsync(path, soup); SaveManagerEvents.current.AllProfilesSaved(SaveManager.profiles); }
// Save all profiles to profiles.dat public static void SaveAllProfiles(string path) { ProfilesListWrapper profiles = new ProfilesListWrapper() { Profiles = SaveManager.profiles }; string json = JsonUtility.ToJson(profiles); // Encrypting process Rijndael crypto = new Rijndael(); byte[] soup = crypto.Encrypt(json, JsonEncryptedKeyProfiles); File.WriteAllBytes(path, soup); SaveManagerEvents.current.AllProfilesSaved(SaveManager.profiles); }