Sample code for 30+ languages & platforms
Tcl

Example: Crypt2.EncryptEncoded method

Demonstrates how to call the EncryptEncoded method.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

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"

# Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A
# and return the encrypted bytes using the lowercase hex encoding.
CkCrypt2_put_EncodingMode $crypt "hex_lower"
set encrypted [CkCrypt2_encryptEncoded $crypt "000102030405060708090a"]
puts "$encrypted"

# Output:
# 9da2ae71a5378487114b430e5e230378

set decrypted [CkCrypt2_decryptEncoded $crypt $encrypted]
puts "$decrypted"

# Output:
# 000102030405060708090a

delete_CkCrypt2 $crypt