So you just need the pkcs8 key.
CngKeyCreationParameters ckcParams = new CngKeyCreationParameters() { ExportPolicy = CngExportPolicies.AllowExportPlainText, KeyCreationOptions = CngKeyCreationOptions.None, KeyUsage = CngKeyUsages.AllUsages, }; ckcParams.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None)); myCngKey = CngKey.Create(CngAlgorithm.Rsa, null, ckcParams); byte[] privatePlainTextBlob = myCngKey.Export(CngKeyBlobFormat.Pkcs8PrivateBlob); Console.WriteLine(Convert.ToBase64String(privatePlainTextBlob)); }
Your key pair is now contained in the PKCS # 8 ASN.1 encoded string.
source share