Config: Clean up

This commit is contained in:
Liza 2023-02-15 13:34:44 +01:00
parent d1cb7e08f2
commit e7c2cd426b

View File

@ -9,7 +9,7 @@ namespace Pal.Client.Configuration
{ {
public class AccountConfigurationV7 : IAccountConfiguration public class AccountConfigurationV7 : IAccountConfiguration
{ {
private const int EntropyLength = 16; private const int DefaultEntropyLength = 16;
[JsonConstructor] [JsonConstructor]
public AccountConfigurationV7() public AccountConfigurationV7()
@ -92,7 +92,7 @@ namespace Pal.Client.Configuration
{ {
try try
{ {
byte[] entropy = RandomNumberGenerator.GetBytes(EntropyLength); byte[] entropy = RandomNumberGenerator.GetBytes(DefaultEntropyLength);
byte[] guidBytes = ProtectedData.Protect(g.ToByteArray(), entropy, DataProtectionScope.CurrentUser); byte[] guidBytes = ProtectedData.Protect(g.ToByteArray(), entropy, DataProtectionScope.CurrentUser);
return (Convert.ToBase64String(guidBytes), entropy, EFormat.UseProtectedData); return (Convert.ToBase64String(guidBytes), entropy, EFormat.UseProtectedData);
} }
@ -116,7 +116,7 @@ namespace Pal.Client.Configuration
return true; return true;
} }
} }
else if (Format == EFormat.UseProtectedData && Entropy is { Length: < EntropyLength }) else if (Format == EFormat.UseProtectedData && Entropy is { Length: < DefaultEntropyLength })
{ {
Guid? g = DecryptAccountId(); Guid? g = DecryptAccountId();
if (g != null) if (g != null)