using System.Security.Cryptography; namespace AuthHex; /// /// Utility class to generate RSA key pairs for JWT authentication. /// Run this once to generate keys and copy them to appsettings.json /// public class RsaKeyGenerator { public static void GenerateAndPrintKeys() { using var rsa = RSA.Create(2048); var privateKey = rsa.ToXmlString(true); // includes private key var publicKey = rsa.ToXmlString(false); // public key only Console.WriteLine("=== RSA Private Key (Keep this SECRET!) ==="); Console.WriteLine(privateKey); Console.WriteLine(); Console.WriteLine("=== RSA Public Key ==="); Console.WriteLine(publicKey); Console.WriteLine(); Console.WriteLine("Copy the Private Key to appsettings.json -> Jwt:RsaPrivateKey"); Console.WriteLine("Copy the Public Key to appsettings.json -> Jwt:RsaPublicKey"); Console.WriteLine(); Console.WriteLine("IMPORTANT: Never commit the private key to source control!"); Console.WriteLine("Consider using Azure Key Vault or environment variables for production."); } }