using System; using System.IO; using System.Security.Cryptography; namespace LicenseGenerator.Commands { internal static class KeygenCommand { internal static void Execute() { using (var rsa = new RSACryptoServiceProvider(2048)) { string privateXml = rsa.ToXmlString(true); string publicXml = rsa.ToXmlString(false); File.WriteAllText("private.key.xml", privateXml); Console.WriteLine("=== PUBLIC KEY XML -- paste into LicenseValidator.cs ==="); Console.WriteLine(publicXml); Console.WriteLine("========================================================"); Console.WriteLine("Private key saved: private.key.xml"); Console.WriteLine("KEEP private.key.xml SECRET -- never distribute it."); } } } }