From 2d367b55e3cf4265770b089a405903ee075caec9 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 19 Jan 2025 23:06:49 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20SimpleEncryptionHelper=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20DataProtectionScope=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/SimpleEncryptionHelper.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MaaWpfGui/Helper/SimpleEncryptionHelper.cs b/src/MaaWpfGui/Helper/SimpleEncryptionHelper.cs index dbc0a2cd6e..54ab5794bf 100644 --- a/src/MaaWpfGui/Helper/SimpleEncryptionHelper.cs +++ b/src/MaaWpfGui/Helper/SimpleEncryptionHelper.cs @@ -9,7 +9,7 @@ public static class SimpleEncryptionHelper { private static readonly ILogger _logger = Log.ForContext("SourceContext", "SimpleEncryptionHelper"); - public static string Encrypt(string plainText) + public static string Encrypt(string plainText, DataProtectionScope dataProtectionScope = DataProtectionScope.CurrentUser) { if (string.IsNullOrEmpty(plainText)) { @@ -19,7 +19,7 @@ public static class SimpleEncryptionHelper try { var data = Encoding.UTF8.GetBytes(plainText); - var encryptedData = ProtectedData.Protect(data, null, DataProtectionScope.CurrentUser); + var encryptedData = ProtectedData.Protect(data, null, dataProtectionScope); return Convert.ToBase64String(encryptedData); } catch (Exception e) @@ -29,7 +29,7 @@ public static class SimpleEncryptionHelper } } - public static string Decrypt(string encryptedText) + public static string Decrypt(string encryptedText, DataProtectionScope dataProtectionScope = DataProtectionScope.CurrentUser) { if (string.IsNullOrEmpty(encryptedText)) { @@ -39,7 +39,7 @@ public static class SimpleEncryptionHelper try { var data = Convert.FromBase64String(encryptedText); - var decryptedData = ProtectedData.Unprotect(data, null, DataProtectionScope.CurrentUser); + var decryptedData = ProtectedData.Unprotect(data, null, dataProtectionScope); return Encoding.UTF8.GetString(decryptedData); } catch (Exception e)