Sample code for 30+ languages & platforms
Tcl

Example: Crypt2.ClearEncryptCerts method

Demonstrates how to call the ClearEncryptCerts method.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set crypt [new_CkCrypt2]

# Tell the crypt object to use 3 certificates.
# Do this by calling AddEncryptCert for each certificate.

set cert1 [new_CkCert]

# ...
# Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
# ...
CkCrypt2_AddEncryptCert $crypt $cert1

set cert2 [new_CkCert]

# ...
CkCrypt2_AddEncryptCert $crypt $cert2

set cert3 [new_CkCert]

# ...
CkCrypt2_AddEncryptCert $crypt $cert3

# Params for public-key encryption to create PKCS7 enveloped-data
CkCrypt2_put_CryptAlgorithm $crypt "pki"
CkCrypt2_put_Pkcs7CryptAlg $crypt "aes"
CkCrypt2_put_KeyLength $crypt 256
CkCrypt2_put_OaepHash $crypt "sha256"
CkCrypt2_put_OaepPadding $crypt 1

set bd [new_CkBinData]

# ...
set success [CkCrypt2_EncryptBd $crypt $bd]

# Let's say we now want to encrypt something else with different certs..
# First clear the encryption certs.
CkCrypt2_ClearEncryptCerts $crypt

set cert4 [new_CkCert]

# ...
CkCrypt2_AddEncryptCert $crypt $cert4

set cert5 [new_CkCert]

# ...
CkCrypt2_AddEncryptCert $crypt $cert5

# ...
# ...

# Encrypt using cert4 and cert5.
set success [CkCrypt2_EncryptBd $crypt $bd]

delete_CkCrypt2 $crypt
delete_CkCert $cert1
delete_CkCert $cert2
delete_CkCert $cert3
delete_CkBinData $bd
delete_CkCert $cert4
delete_CkCert $cert5