Files
PnvPanel/backend/src/PnvPanel.Infrastructure/Security/DataProtectionSecretProtector.cs
T

21 lines
641 B
C#

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);
}