mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
chore: SimpleEncryptionHelper 新增 DataProtectionScope 参数
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user