Tcl
Tcl
RSA Import Public Key from Certificate PEM
See more RSA Examples
Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
set cert [new_CkCert]
set success [CkCert_LoadFromFile $cert "qa_data/pem/mf_public_rsa.pem"]
if {$success == 0} then {
puts [CkCert_lastErrorText $cert]
delete_CkCert $cert
exit
}
set pubKey [new_CkPublicKey]
CkCert_GetPublicKey $cert $pubKey
set rsa [new_CkRsa]
CkRsa_UsePublicKey $rsa $pubKey
CkRsa_put_EncodingMode $rsa "base64"
set encryptedStr [CkRsa_encryptStringENC $rsa "hello" 0]
puts "encrypted string = $encryptedStr"
delete_CkCert $cert
delete_CkPublicKey $pubKey
delete_CkRsa $rsa