[VB6 equivalent: RSA_ReadPublicKey
]
Dim strCertFile As String
Dim strKeyFile As String
Dim sbPublicKey As StringBuilder
Dim nRet As Integer
strCertFile = "AliceRSASignByCarl.cer"
sbPublicKey = Rsa.ReadPublicKey(strCertFile)
Console.WriteLine("Rsa.ReadPublicKey returns " & sbPublicKey.Length & " (expecting +ve)")
If sbPublicKey.Length = 0 Then
Console.WriteLine("ERROR: " & General.LastError())
Exit Sub
End If
Console.WriteLine("Public key is " & Rsa.KeyBits(sbPublicKey.ToString()) & " bits long")
' Now save as a PKCS#1 public key file
strKeyFile = "AlicePubRSA.pub"
nRet = Rsa.SavePublicKey(strKeyFile, sbPublicKey.ToString(), 0)
Console.WriteLine("RSA_SavePublicKey returns " & nRet)
If nRet = 0 Then
Console.WriteLine("Saved as public key file '" & strKeyFile & "'")
Else
Console.WriteLine("ERROR: " & General.LastError())
End If
See Also:
Rsa.ReadPublicKey Method