Sample code for 30+ languages & platforms
PowerBuilder

Duplicate openssl smime -encrypt -binary -aes-256-cbc -in some_file.dat -out some_file.dat.enc -outform DER cert.crt

See more OpenSSL Examples

Demonstrates how to encrypt to binary DER using 256-bit AES (CBC mode) as the underlying symmetric encryption algorithm, to produce PKCS7 enveloped data (binary DER).

Duplicates 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_Crypt

li_Success = 0

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

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/hello.txt")
// Assuming success..

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

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

loo_Crypt.CryptAlgorithm = "PKI"

// Indicate the underlying symmetric encryption to be used:
loo_Crypt.Pkcs7CryptAlg = "aes"
loo_Crypt.KeyLength = 256
loo_Crypt.CipherMode = "cbc"

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

Write-Debug "Success."


destroy loo_Cert
destroy loo_Bd
destroy loo_Crypt