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
(PowerBuilder) Load PEM Public/Private Key into RSA ObjectDemonstrates how to load a PEM key into the Chilkat RSA object.
integer li_rc oleobject loo_Rsa string ls_PublicKeyPem oleobject loo_Pubkey integer li_Success string ls_PublicKeyXml string ls_PrivateKeyPem oleobject loo_Privkey string ls_PrivateKeyXml // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Rsa = create oleobject // Use "Chilkat_9_5_0.Rsa" for versions of Chilkat < 10.0.0 li_rc = loo_Rsa.ConnectToNewObject("Chilkat.Rsa") if li_rc < 0 then destroy loo_Rsa MessageBox("Error","Connecting to COM object failed") return end if // First demonstrate importing a PEM public key: ls_PublicKeyPem = "PEM public-key data goes here" loo_Pubkey = create oleobject // Use "Chilkat_9_5_0.PublicKey" for versions of Chilkat < 10.0.0 li_rc = loo_Pubkey.ConnectToNewObject("Chilkat.PublicKey") li_Success = loo_Pubkey.LoadFromString(ls_PublicKeyPem) if li_Success <> 1 then Write-Debug loo_Pubkey.LastErrorText destroy loo_Rsa destroy loo_Pubkey return end if ls_PublicKeyXml = loo_Pubkey.GetXml() li_Success = loo_Rsa.ImportPublicKey(ls_PublicKeyXml) if li_Success <> 1 then Write-Debug loo_Rsa.LastErrorText destroy loo_Rsa destroy loo_Pubkey return end if // Demonstrate importing a PEM private key: ls_PrivateKeyPem = "PEM private-key data goes here" loo_Privkey = create oleobject // Use "Chilkat_9_5_0.PrivateKey" for versions of Chilkat < 10.0.0 li_rc = loo_Privkey.ConnectToNewObject("Chilkat.PrivateKey") // If the private key PEM is protected with a password, then // call LoadEncryptedPem. Otherwise call LoadPem. li_Success = loo_Privkey.LoadPem(ls_PrivateKeyPem) if li_Success <> 1 then Write-Debug loo_Privkey.LastErrorText destroy loo_Rsa destroy loo_Pubkey destroy loo_Privkey return end if ls_PrivateKeyXml = loo_Privkey.GetXml() li_Success = loo_Rsa.ImportPrivateKey(ls_PrivateKeyXml) if li_Success <> 1 then Write-Debug loo_Rsa.LastErrorText destroy loo_Rsa destroy loo_Pubkey destroy loo_Privkey return end if Write-Debug "OK!" destroy loo_Rsa destroy loo_Pubkey destroy loo_Privkey |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.