Skip to content

Commit

Permalink
Update MauiSettingsGeneric.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasReitberger committed Apr 4, 2024
1 parent 9d685d5 commit 7f4e74a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/MauiSettings/MauiSettingsGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ List<MauiSettingAttribute> settingBaseAttributes
{
if (settingsInfo.Value is string secureString)
{
if (settingsInfo.Encrypt)
if (settingsInfo.Encrypt && !string.IsNullOrEmpty(secureString))
{
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
Expand Down Expand Up @@ -823,8 +823,10 @@ List<MauiSettingAttribute> settingBaseAttributes
{
if (settingsInfo.Value is string secureString)
{
if (settingsInfo.Encrypt && !string.IsNullOrEmpty(key))
if (settingsInfo.Encrypt && !string.IsNullOrEmpty(secureString))
{
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
// Encrypt string
try
{
Expand Down Expand Up @@ -877,9 +879,11 @@ List<MauiSettingAttribute> settingBaseAttributes
{
if (settingsInfo.Value is string secureString)
{
if (settingsInfo.Encrypt && !string.IsNullOrEmpty(key))
if (settingsInfo.Encrypt && !string.IsNullOrEmpty(secureString))
{
// Decrypt string
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
// Encrypt string
try
{
string encryptedString = EncryptionManager.EncryptStringToBase64String(secureString, key);
Expand Down

0 comments on commit 7f4e74a

Please sign in to comment.