Files
CVRManager/Services/TokenVault.cs
T
Exterrata 9bb4f85802 CVR Manager 1.0.0
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 02:46:35 -04:00

18 lines
589 B
C#

using System.Security.Cryptography;
using System.Text;
namespace CVRManager.Services;
public static class TokenVault
{
public static string Protect(string token) =>
Convert.ToBase64String(ProtectedData.Protect(Encoding.UTF8.GetBytes(token), null, DataProtectionScope.CurrentUser));
public static string Unprotect(string stored)
{
if (string.IsNullOrEmpty(stored)) return "";
try { return Encoding.UTF8.GetString(ProtectedData.Unprotect(Convert.FromBase64String(stored), null, DataProtectionScope.CurrentUser)); }
catch { return ""; }
}
}