Sample code for 30+ languages & platforms
Xbase++

Example: Crypt2.DecryptStringENC method

Demonstrates how to call the DecryptStringENC method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL oCrypt
LOCAL cEncodedEncrypted
LOCAL cOriginalText

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

oCrypt := CreateObject("Chilkat.Crypt2")

oCrypt:CryptAlgorithm := "aes"
oCrypt:CipherMode := "cbc"
oCrypt:KeyLength := 128
oCrypt:SetEncodedKey("000102030405060708090A0B0C0D0E0F", "hex")
oCrypt:SetEncodedIV("000102030405060708090A0B0C0D0E0F", "hex")
oCrypt:EncodingMode := "base64"

//  Return the base64 encoded encrypted bytes
cEncodedEncrypted := oCrypt:EncryptStringENC("Hello World!")
? "Encrypted: " + cEncodedEncrypted

//  Output:
//  Encrypted: qiq+IFhcjTkEIkZyf31V/g==

//  Decrypt
cOriginalText := oCrypt:DecryptStringENC(cEncodedEncrypted)

? "Decrypted: " + cOriginalText

//  Output:
//  Decrypted: Hello World!

oCrypt:destroy()