CryptoSys PKI Pro Manual

Example: Rsa.KeyHashCode  Rsa.ReadPrivateKey  Rsa.ReadPrivateKeyInfo  Rsa.SaveEncPrivateKey 

[VB6 equivalent: RSA_ReadPrivateKeyInfo]

Dim strPriFile As String
Dim strEPKFile As String
Dim strPrivateKey As String
Dim strPK1 As String
Dim nRet As Integer

' Read in Bob's unencrypted PrivateKeyInfo data
strPriFile = "BobPrivRSAEncrypt.pri"
strPrivateKey = Rsa.ReadPrivateKey(strPriFile, "").ToString()
If strPrivateKey.Length = 0 Then
    Console.WriteLine("Failed to read Private Key file")
    Exit Sub
End If
' Now we save it with a password
strEPKFile = "BobPrivRSAEncrypt.p8e"
nRet = Rsa.SaveEncPrivateKey(strEPKFile, strPrivateKey, 1000, "password", 0, 0)
Console.WriteLine("RSA_SaveEncPrivateKey returns " & nRet)

' Check we can read it
strPK1 = Rsa.ReadPrivateKey(strEPKFile, "password").ToString()

' To compare these strings, use the RSA_KeyHashCode function
Console.WriteLine("{0,8:X}", Rsa.KeyHashCode(strPK1))
Console.WriteLine("{0,8:X}", Rsa.KeyHashCode(strPrivateKey))
If Rsa.KeyHashCode(strPK1) = Rsa.KeyHashCode(strPrivateKey) Then
    Console.WriteLine("Key string values match.")
Else
    Console.WriteLine("ERROR: key strings do not match.")
End If

See Also:
Rsa.ReadPrivateKeyInfo Method - @deprecated

[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.