CryptoSys PKI Pro Manual

Example: Rsa.KeyBits  Rsa.ReadPublicKey  Rsa.SavePublicKey 

[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

[Contents] [Index]

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

Copyright © 2004-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-09-18T10:02:53Z.