Sample code for 30+ languages & platforms
PowerBuilder

Duplicate openssl smime -decrypt -in some_file.dat.enc -binary -inform DER -inkey private.key -out some_file.dat

See more OpenSSL Examples

Demonstrates how to decrypt binary DER that was encrypted using the following openssl command:
openssl smime -encrypt -binary -aes-256-cbc -in some_file.dat -out some_file.dat.enc -outform DER cert.crt

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Cert
oleobject loo_Bd
oleobject loo_PrivKey
oleobject loo_Crypt

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// Duplicates the following openssl command:
// openssl smime -decrypt -in hello.txt.enc -binary -inform DER -inkey private.key -out hello.txt

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.LoadFromFile("qa_data/openssl/EE.cer")
if li_Success = 0 then
    Write-Debug loo_Cert.LastErrorText
    destroy loo_Cert
    return
end if

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

li_Success = loo_Bd.LoadFile("qa_data/openssl/EE.key")
// Assuming success..

loo_PrivKey = create oleobject
li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey")

li_Success = loo_PrivKey.LoadAnyFormat(loo_Bd,"")
if li_Success = 0 then
    Write-Debug loo_PrivKey.LastErrorText
    destroy loo_Cert
    destroy loo_Bd
    destroy loo_PrivKey
    return
end if

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

li_Success = loo_Crypt.SetDecryptCert2(loo_Cert,loo_PrivKey)
if li_Success = 0 then
    Write-Debug loo_Crypt.LastErrorText
    destroy loo_Cert
    destroy loo_Bd
    destroy loo_PrivKey
    destroy loo_Crypt
    return
end if

loo_Crypt.CryptAlgorithm = "PKI"
li_Success = loo_Crypt.CkDecryptFile("qa_data/openssl/hello.txt.enc","qa_output/hello.txt")
if li_Success = 0 then
    Write-Debug loo_Crypt.LastErrorText
    destroy loo_Cert
    destroy loo_Bd
    destroy loo_PrivKey
    destroy loo_Crypt
    return
end if

Write-Debug "Success."


destroy loo_Cert
destroy loo_Bd
destroy loo_PrivKey
destroy loo_Crypt