CryptoSys PKI Pro Manual

Example: Rsa.CheckKey  Rsa.KeyBits  Rsa.KeyHashCode  Rsa.ReadPrivateKey  Rsa.ReadPrivateKeyFromPFX  Wipe.String 

[VB6 equivalent: RSA_ReadPrivateKeyFromPFX]

Dim strPfxFile As String
Dim sbPrivateKey As StringBuilder
Dim sbPassword As StringBuilder
Dim nCode As Integer
Dim nRet As Integer

strPfxFile = "bob.pfx"
sbPassword = New StringBuilder("password")

' Read private key from PFX file into internal string form
sbPrivateKey = Rsa.ReadPrivateKey(strPfxFile, sbPassword.ToString())
If sbPrivateKey.Length = 0 Then Exit Sub ' Catch error here

' Display some info about it
Console.WriteLine("Private key length = {0} bits", Rsa.KeyBits(sbPrivateKey.ToString()))
nCode = Rsa.KeyHashCode(sbPrivateKey.ToString())
Console.WriteLine("KeyHashCode={0,8:X}", nCode)
nRet = Rsa.CheckKey(sbPrivateKey)
Console.WriteLine("Rsa.CheckKey returns " & nRet & ": (PKI_VALID_PRIVATEKEY=" & 0 & ")")

' Clean up
Wipe.String(sbPrivateKey)
Wipe.String(sbPassword)

See Also:
Rsa.ReadPrivateKeyFromPFX Method - @deprecated

[Contents] [Index]

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

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