Sample code for 30+ languages & platforms
PowerBuilder

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Cert
oleobject loo_Decrypt
oleobject loo_Bd

li_Success = 0

loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")
if li_rc < 0 then
    destroy loo_Cert
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_Success = loo_Cert.LoadPfxFile("c:/pfx_files/my.pfx","password")
if li_Success <> 1 then
    Write-Debug loo_Cert.LastErrorText
    destroy loo_Cert
    return
end if

loo_Decrypt = create oleobject
li_rc = loo_Decrypt.ConnectToNewObject("Chilkat.Crypt2")

loo_Decrypt.CryptAlgorithm = "pki"

li_Success = loo_Decrypt.SetDecryptCert(loo_Cert)
if li_Success <> 1 then
    Write-Debug loo_Decrypt.LastErrorText
    destroy loo_Cert
    destroy loo_Decrypt
    return
end if

loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")

li_Success = loo_Bd.LoadFile("c:/someDir/pkcs7_encrypted.dat")

li_Success = loo_Decrypt.DecryptBd(loo_Bd)
if li_Success <> 1 then
    Write-Debug loo_Decrypt.LastErrorText
    destroy loo_Cert
    destroy loo_Decrypt
    destroy loo_Bd
    return
end if

// bd contains the decrypted content.


destroy loo_Cert
destroy loo_Decrypt
destroy loo_Bd