CryptoSys PKI Toolkit Manual

Example: Rsa.Format  Rsa.KeyBits  Rsa.ReadEncPrivateKey  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.epk"
strPriFile = "rsa508.pri"
strPEMFile = "rsa508.pem"
strPassword = "password"

' Read in the deciphered private key string
strPrivateKey = Rsa.ReadEncPrivateKey(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(strPriFile, strPrivateKey, Rsa.Format.PEM)
Console.WriteLine("Rsa.SavePrivateKeyInfo returns " & nRet)

See Also:
Rsa.SavePrivateKeyInfo Method

[Contents] [Index]

[HOME]   [NEXT: Example: Rsa.KeyBits ...]

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