CryptoSys PKI Pro Manual

Example: Rsa.Format  Rsa.KeyBits  Rsa.ReadPrivateKey  Rsa.SavePrivateKeyInfo 

[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

[Contents] [Index]

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

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