Sample code for 30+ languages & platforms
Tcl

RSA Import Private Key

See more RSA Examples

Shows how to select/import a private key for RSA signing or decryption.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set privKey [new_CkPrivateKey]

set password "secret"
# In all Chilkat methods expecting a path, you pass either absolute or relative paths.
set success [CkPrivateKey_LoadAnyFormatFile $privKey "rsaKeys/myTestRsaPrivate.pem" $password]
if {$success == 0} then {
    puts [CkPrivateKey_lastErrorText $privKey]
    delete_CkPrivateKey $privKey
    exit
}

set rsa [new_CkRsa]

# Tell the RSA object to use the private key (i.e. import the private key)
CkRsa_UsePrivateKey $rsa $privKey

delete_CkPrivateKey $privKey
delete_CkRsa $rsa