9bb4f85802
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
18 lines
589 B
C#
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 ""; }
|
|
}
|
|
}
|