CryptoSys PKI Toolkit Manual

Example: Cms.ReadEnvDataToFile  Rsa.ReadEncPrivateKey  Wipe.String 

[VB6 equivalent: CMS_ReadEnvData]

Dim nRet As Integer
Dim strFileIn As String
Dim strFileOut As String
Dim sbPrivateKey As StringBuilder

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

' Decrypt the input file, send plaintext to new output file
strFileIn = "cmsalice2bob.p7m"
strFileOut = "fromalice.txt"
nRet = Cms.ReadEnvDataToFile(strFileOut, strFileIn, "", sbPrivateKey.ToString(), 0)
Console.WriteLine("CMS_ReadEnvData returns " & nRet)

' Clean up
Wipe.String(sbPrivateKey)

See Also:
Cms.ReadEnvDataToFile Method

[Contents] [Index]

[HOME]   [NEXT: Example: Cms.QueryEnvData ...]

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