Sample code for 30+ languages & platforms
Lianja

Example: Crypt2.DecryptStringENC method

Demonstrates how to call the DecryptStringENC method.

Chilkat Lianja Downloads

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

loCrypt = createobject("CkCrypt2")

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

// Return the base64 encoded encrypted bytes
lcEncodedEncrypted = loCrypt.EncryptStringENC("Hello World!")
? "Encrypted: " + lcEncodedEncrypted

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

// Decrypt
lcOriginalText = loCrypt.DecryptStringENC(lcEncodedEncrypted)

? "Decrypted: " + lcOriginalText

// Output:
// Decrypted: Hello World!


release loCrypt