[VB6 equivalent: RSA_SavePrivateKeyInfo
]
Dim strEPKFile As String Dim strPriFile As String Dim strPEMFile As String Dim strPassword As String Dim strPrivateKey As String Dim nRet As Integer strEPKFile = "rsa508.p8e" strPriFile = "rsa508.pri" strPEMFile = "rsa508.pem" strPassword = "password" ' Read in the deciphered private key string strPrivateKey = Rsa.ReadPrivateKey(strEPKFile, strPassword).ToString() If strPrivateKey.Length = 0 Then Console.WriteLine("Unable to retrieve private key") Exit Sub End If Console.WriteLine("Key size=" & Rsa.KeyBits(strPrivateKey) & " bits") ' Save as unencrypted PrivateKeyInfo file nRet = Rsa.SavePrivateKeyInfo(strPriFile, strPrivateKey, Rsa.Format.Binary) Console.WriteLine("Rsa.SavePrivateKeyInfo returns " & nRet) ' Save as unencrypted PEM-format file nRet = Rsa.SavePrivateKeyInfo(strPEMFile, strPrivateKey, Rsa.Format.PEM) Console.WriteLine("Rsa.SavePrivateKeyInfo returns " & nRet)
See Also:
Rsa.SavePrivateKeyInfo Method