(Tcl) Get Base64 Public Key from Private Key
Demonstrates how to get the public key in base64 format from a private key.
load ./chilkat.dll
# Load a private key from base64.
set bd [new_CkBinData]
set success [CkBinData_AppendEncoded $bd "MHQCA....n0Q==" "base64"]
set privKey [new_CkPrivateKey]
set success [CkPrivateKey_LoadAnyFormat $privKey $bd ""]
if {$success == 0} then {
puts [CkPrivateKey_lastErrorText $privKey]
delete_CkBinData $bd
delete_CkPrivateKey $privKey
exit
}
# pubKey is a CkPublicKey
set pubKey [CkPrivateKey_GetPublicKey $privKey]
if {[CkPrivateKey_get_LastMethodSuccess $privKey] == 0} then {
puts [CkPrivateKey_lastErrorText $privKey]
delete_CkBinData $bd
delete_CkPrivateKey $privKey
exit
}
set pubKeyBase64 [CkPublicKey_getEncoded $pubKey 1 "base64"]
puts "$pubKeyBase64"
delete_CkPublicKey $pubKey
delete_CkBinData $bd
delete_CkPrivateKey $privKey
|