using Microsoft.AspNetCore.DataProtection; using PnvPanel.Application.Common.Interfaces; namespace PnvPanel.Infrastructure.Security; internal sealed class DataProtectionSecretProtector : ISecretProtector { private const string Purpose = "PnvPanel.NodeCredentials.v1"; private readonly IDataProtector _protector; public DataProtectionSecretProtector(IDataProtectionProvider provider) { _protector = provider.CreateProtector(Purpose); } public string Protect(string plaintext) => _protector.Protect(plaintext); public string Unprotect(string protectedValue) => _protector.Unprotect(protectedValue); }