CryptoSys PKI Pro Manual

Example: Rsa.GetPublicKeyFromCert  Rsa.KeyBits  Rsa.SavePublicKey 

[VB6 equivalent: RSA_GetPublicKeyFromCert]

Dim strCertFile As String
Dim strKeyFile As String
Dim sbPublicKey As StringBuilder
Dim nRet As Integer

strCertFile = "AliceRSASignByCarl.cer"
sbPublicKey = Rsa.GetPublicKeyFromCert(strCertFile)
Console.WriteLine("RSA_GetPublicKeyFromCert 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.GetPublicKeyFromCert Method - @deprecated

[Contents] [Index]

[PREV: Example: Rsa.CheckKey ...]   [Contents]   [Index]   
   [NEXT: Example: Rsa.GetPublicKeyFromCert ...]

Copyright © 2004-19 D.I. Management Services Pty Ltd. All rights reserved.