public static void SaveConfig(GameConsolePanelSettingConfig config) { string json = SimpleJsonUtils.ToJson(config); byte[] keyBytes = Convert.FromBase64String(KeyBase64); string _aesKeyStr = Encoding.UTF8.GetString(keyBytes); json = AESUtils.AESEncrypt(json, _aesKeyStr); CreateTextFile(SavePathDir + GameConsolePanelSettingConfig.FileName + ".txt", json); }
public static GameConsolePanelSettingConfig GetCofig() { if (Application.isPlaying) { if (configData != null) { return(configData); } } TextAsset textAsset = Resources.Load <TextAsset>(FileName); if (textAsset == null || string.IsNullOrEmpty(textAsset.text)) { configData = new GameConsolePanelSettingConfig(); } else { string json = textAsset.text; try { byte[] keyBytes = Convert.FromBase64String(KeyBase64); string _aesKeyStr = Encoding.UTF8.GetString(keyBytes); json = AESUtils.AESDecrypt(json, _aesKeyStr); } catch (Exception e) { Debug.LogError(e); } configData = SimpleJsonUtils.FromJson <GameConsolePanelSettingConfig>(json); if (configData == null) { configData = new GameConsolePanelSettingConfig(); } } return(configData); }