Sample code for 30+ languages & platforms
Tcl

Example: Crypt2.DecryptStringENC method

Demonstrates how to call the DecryptStringENC method.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

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

set crypt [new_CkCrypt2]

CkCrypt2_put_CryptAlgorithm $crypt "aes"
CkCrypt2_put_CipherMode $crypt "cbc"
CkCrypt2_put_KeyLength $crypt 128
CkCrypt2_SetEncodedKey $crypt "000102030405060708090A0B0C0D0E0F" "hex"
CkCrypt2_SetEncodedIV $crypt "000102030405060708090A0B0C0D0E0F" "hex"
CkCrypt2_put_EncodingMode $crypt "base64"

# Return the base64 encoded encrypted bytes
set encodedEncrypted [CkCrypt2_encryptStringENC $crypt "Hello World!"]
puts "Encrypted: $encodedEncrypted"

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

# Decrypt
set originalText [CkCrypt2_decryptStringENC $crypt $encodedEncrypted]

puts "Decrypted: $originalText"

# Output:
# Decrypted: Hello World!

delete_CkCrypt2 $crypt