From c2351ae21b0384a9ffacaefcf4c4eb677ff8338e Mon Sep 17 00:00:00 2001
From: croire <1432593898@qq.com>
Date: Wed, 2 Feb 2022 11:13:48 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=96=87=E4=BB=B6=E5=9C=A8re?=
=?UTF-8?q?lease=E6=97=B6=E5=8A=A0=E5=AF=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DownKyi.Core/Settings/SettingsManager.cs | 37 ++++++++++++++++++++----
DownKyi.Core/Storage/Constant.cs | 2 +-
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/DownKyi.Core/Settings/SettingsManager.cs b/DownKyi.Core/Settings/SettingsManager.cs
index 4530a94..cbed751 100644
--- a/DownKyi.Core/Settings/SettingsManager.cs
+++ b/DownKyi.Core/Settings/SettingsManager.cs
@@ -3,12 +3,31 @@ using Newtonsoft.Json;
using System;
using System.IO;
+#if DEBUG
+#else
+using DownKyi.Core.Utils.Encryptor;
+#endif
+
namespace DownKyi.Core.Settings
{
public partial class SettingsManager
{
private static SettingsManager instance;
+ // 内存中保存一份配置
+ private AppSettings appSettings;
+
+#if DEBUG
+ // 设置的配置文件
+ private readonly string settingsName = Storage.StorageManager.GetSettings() + "_debug.json";
+#else
+ // 设置的配置文件
+ private readonly string settingsName = Storage.StorageManager.GetSettings();
+
+ // 密钥
+ private readonly string password = "YO1J$4#p";
+#endif
+
///
/// 获取SettingsManager实例
///
@@ -30,12 +49,6 @@ namespace DownKyi.Core.Settings
appSettings = GetSettings();
}
- // 内存中保存一份配置
- private AppSettings appSettings;
-
- // 设置的配置文件
- private readonly string settingsName = Storage.StorageManager.GetSettings();
-
///
/// 获取AppSettingsModel
///
@@ -48,6 +61,12 @@ namespace DownKyi.Core.Settings
string jsonWordTemplate = streamReader.ReadToEnd();
streamReader.Close();
+#if DEBUG
+#else
+ // 解密字符串
+ jsonWordTemplate = Encryptor.DecryptString(jsonWordTemplate, password);
+#endif
+
return JsonConvert.DeserializeObject(jsonWordTemplate);
}
catch (Exception e)
@@ -65,6 +84,12 @@ namespace DownKyi.Core.Settings
{
string json = JsonConvert.SerializeObject(appSettings);
+#if DEBUG
+#else
+ // 加密字符串
+ json = Encryptor.EncryptString(json, password);
+#endif
+
try
{
File.WriteAllText(settingsName, json);
diff --git a/DownKyi.Core/Storage/Constant.cs b/DownKyi.Core/Storage/Constant.cs
index 633ece9..55d340c 100644
--- a/DownKyi.Core/Storage/Constant.cs
+++ b/DownKyi.Core/Storage/Constant.cs
@@ -27,7 +27,7 @@ namespace DownKyi.Core.Storage
public static string Config { get; } = $"{Root}/Config";
// 设置
- public static string Settings { get; } = $"{Config}/Settings.json";
+ public static string Settings { get; } = $"{Config}/Settings";
// 登录cookies
public static string Login { get; } = $"{Config}/Login";