CryptoSys PKI Pro Manual

Example: Cms.QueryEnvData  Cms.ReadEnvDataToString  Rsa.ReadPrivateKey  Wipe.String 

[VB6 equivalent: CMS_ReadEnvDataToString]

Dim sbPrivateKey As StringBuilder
Dim strFileIn As String
Dim strDataOut As String
Dim strSize As String

strFileIn = "cms2bobandcarl.p7m"

' First, Bob reads his private key into a string
sbPrivateKey = Rsa.ReadPrivateKey("BobPrivRSAEncrypt.p8e", "password")
If sbPrivateKey.Length = 0 Then
    Console.WriteLine("Cannot read private key")
    Exit Sub
End If

' Query the size of encrypted content (no need for an output buffer)
strSize = Cms.QueryEnvData(strFileIn, "sizeofEncryptedContent")
Console.WriteLine("CMS_QueryEnvData returns " & strSize)

If strSize = "0" Then
    GoTo CleanUp
End If

strDataOut = Cms.ReadEnvDataToString(strFileIn, "", sbPrivateKey.ToString)
Console.WriteLine("CMS_ReadEnvDataToString returns " & strDataOut.Length)
If strDataOut.Length > 0 Then
    Console.WriteLine("Plaintext is '" & strDataOut & "'")
End If

CleanUp:
Wipe.String(sbPrivateKey)

See Also:
Cms.ReadEnvDataToString Method

[Contents] [Index]

[PREV: Example: Cms.ReadEnvData ...]   [Contents]   [Index]   
   [NEXT: Example: Cms.ReadSigData ...]

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