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