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.
24 lines
727 B
C#
24 lines
727 B
C#
using DigitalData.EmailProfiler.Application.Common.Interfaces;
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
|
|
namespace DigitalData.EmailProfiler.Infrastructure.Services;
|
|
|
|
/// <summary>
|
|
/// Encryption service using ASP.NET Core Data Protection API.
|
|
/// Passwords are encrypted at rest in the database.
|
|
/// </summary>
|
|
public class DataProtectionEncryptionService(IDataProtectionProvider Provider) : IEncryptionService
|
|
{
|
|
private readonly IDataProtector Protector = Provider.CreateProtector("EmailProfiler.Passwords");
|
|
|
|
public string Encrypt(string plainText)
|
|
{
|
|
return Protector.Protect(plainText);
|
|
}
|
|
|
|
public string Decrypt(string cipherText)
|
|
{
|
|
return Protector.Unprotect(cipherText);
|
|
}
|
|
}
|