Sample code for 30+ languages & platforms
Tcl

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set crypt [new_CkCrypt2]

set bdEncrypted [new_CkBinData]

set sbPlainText [new_CkStringBuilder]

CkStringBuilder_Append $sbPlainText "Text to be encrypted"

# ...
# Set the secret key ...
# Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
# Set the IV if needed ...
# ...

CkCrypt2_put_Charset $crypt "utf-8"

set success [CkCrypt2_EncryptSb $crypt $sbPlainText $bdEncrypted]
if {$success == 0} then {
    puts [CkCrypt2_lastErrorText $crypt]
    delete_CkCrypt2 $crypt
    delete_CkBinData $bdEncrypted
    delete_CkStringBuilder $sbPlainText
    exit
}


delete_CkCrypt2 $crypt
delete_CkBinData $bdEncrypted
delete_CkStringBuilder $sbPlainText