Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) Load PEM Public/Private Key into RSA ObjectDemonstrates how to load a PEM key into the Chilkat RSA object.
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set rsa [new_CkRsa] # First demonstrate importing a PEM public key: set publicKeyPem "PEM public-key data goes here" set pubkey [new_CkPublicKey] set success [CkPublicKey_LoadFromString $pubkey $publicKeyPem] if {$success != 1} then { puts [CkPublicKey_lastErrorText $pubkey] delete_CkRsa $rsa delete_CkPublicKey $pubkey exit } set publicKeyXml [CkPublicKey_getXml $pubkey] set success [CkRsa_ImportPublicKey $rsa $publicKeyXml] if {$success != 1} then { puts [CkRsa_lastErrorText $rsa] delete_CkRsa $rsa delete_CkPublicKey $pubkey exit } # Demonstrate importing a PEM private key: set privateKeyPem "PEM private-key data goes here" set privkey [new_CkPrivateKey] # If the private key PEM is protected with a password, then # call LoadEncryptedPem. Otherwise call LoadPem. set success [CkPrivateKey_LoadPem $privkey $privateKeyPem] if {$success != 1} then { puts [CkPrivateKey_lastErrorText $privkey] delete_CkRsa $rsa delete_CkPublicKey $pubkey delete_CkPrivateKey $privkey exit } set privateKeyXml [CkPrivateKey_getXml $privkey] set success [CkRsa_ImportPrivateKey $rsa $privateKeyXml] if {$success != 1} then { puts [CkRsa_lastErrorText $rsa] delete_CkRsa $rsa delete_CkPublicKey $pubkey delete_CkPrivateKey $privkey exit } puts "OK!" delete_CkRsa $rsa delete_CkPublicKey $pubkey delete_CkPrivateKey $privkey |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.