Created
February 20, 2026 13:53
-
-
Save swaters86/d920a54a266f58cfca6e6e429d636519 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.Win32; | |
| public static class SecretRegistry | |
| { | |
| private const string KeyPath = @"SOFTWARE\YourCompany\Connector\Secrets"; | |
| public static void SaveClientSecret(string secretPlaintext) | |
| { | |
| string protectedBase64 = DpapiSecretStore.ProtectToBase64(secretPlaintext); | |
| using (var key = Registry.LocalMachine.CreateSubKey(KeyPath, writable: true)) | |
| { | |
| key.SetValue("CognitoClientSecret", protectedBase64, RegistryValueKind.String); | |
| } | |
| } | |
| public static string LoadClientSecret() | |
| { | |
| using (var key = Registry.LocalMachine.OpenSubKey(KeyPath, writable: false)) | |
| { | |
| var protectedBase64 = key?.GetValue("CognitoClientSecret") as string; | |
| return DpapiSecretStore.UnprotectFromBase64(protectedBase64); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment