Refactor EmailAccountDto and improve encryption logic
Refactored `EmailAccountDto` to focus on SMTP-related properties, removing unused fields. Updated `DependencyInjection` to configure data protection with a new key storage path. Simplified `DataProtectionEncryptionService` by removing redundant checks and error handling for encryption and decryption methods.
This commit is contained in:
@@ -13,25 +13,11 @@ public class DataProtectionEncryptionService(IDataProtectionProvider Provider) :
|
||||
|
||||
public string Encrypt(string plainText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(plainText))
|
||||
return string.Empty;
|
||||
|
||||
return Protector.Protect(plainText);
|
||||
}
|
||||
|
||||
public string Decrypt(string cipherText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(cipherText))
|
||||
return string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
return Protector.Unprotect(cipherText);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// If decryption fails, return empty (corrupt data or wrong key)
|
||||
return string.Empty;
|
||||
}
|
||||
return Protector.Unprotect(cipherText);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user