(Tcl) Use Base64 RSA Key to Encrypt
Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.
load ./chilkat.dll
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set pubkey [new_CkPublicKey]
set success [CkPublicKey_LoadBase64 $pubkey "MIICdgIBADA ... A9PXLk+j5A=="]
if {$success != 1} then {
puts [CkPublicKey_lastErrorText $pubkey]
delete_CkPublicKey $pubkey
exit
}
set rsa [new_CkRsa]
set success [CkRsa_ImportPublicKeyObj $rsa $pubkey]
if {$success != 1} then {
puts [CkRsa_lastErrorText $rsa]
delete_CkPublicKey $pubkey
delete_CkRsa $rsa
exit
}
CkRsa_put_EncodingMode $rsa "base64"
set encryptedStr [CkRsa_encryptStringENC $rsa "12345678" 0]
puts "$encryptedStr"
delete_CkPublicKey $pubkey
delete_CkRsa $rsa
|