forked from jawkh/gpgme-sharp-implementation-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
27 lines (20 loc) · 1023 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.DataProtection;
using System.Text;
using System;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using ProtectSecretsWithASPNETCoreDataProtectionAPI;
Console.WriteLine("### Encrypting your Secrets using ASP.NET Core Data Protection API ###\n\n");
Console.WriteLine("### Enter your Secrets and press Enter: ");
string? secretsInClear = null;
while (string.IsNullOrEmpty(secretsInClear))
{
secretsInClear = Console.ReadLine();
}
string encryptedString = SecretsEncryptor.EncryptString(Util.ToSecureString(secretsInClear));
Console.WriteLine("\n-----BEGIN SECRET-----\n{0}", encryptedString); ;
Console.WriteLine("-----END SECRET-----");
Console.WriteLine(string.Format("\n\nDecrypted Payload [For Verifications]: \n{0}", Util.ToInsecureString(SecretsDecryptor.DecryptString(encryptedString))));
Console.WriteLine("\n\nPress Enter to Exit. ");
Console.ReadLine();