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) RSA Encrypt and OpenSSL DecryptDemonstrates how to use Chilkat to RSA encrypt, and then use OpenSSL to decrypt.
integer li_rc oleobject loo_Rsa integer li_Success oleobject loo_PrivKey string ls_PlainText integer li_BUsePrivateKey string ls_EncryptedStr oleobject loo_Bd // This requires 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 li_Success = loo_Rsa.GenerateKey(2048) loo_PrivKey = loo_Rsa.ExportPrivateKeyObj() li_Success = loo_PrivKey.SavePkcs8PemFile("qa_output/privKey.pem") destroy loo_PrivKey loo_Rsa.EncodingMode = "base64" ls_PlainText = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890" li_BUsePrivateKey = 0 ls_EncryptedStr = loo_Rsa.EncryptStringENC(ls_PlainText,li_BUsePrivateKey) loo_Bd = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData") loo_Bd.AppendEncoded(ls_EncryptedStr,"base64") li_Success = loo_Bd.WriteFile("qa_output/enc.dat") // The OpenSSL command to decrypt is: // openssl pkeyutl -in enc.dat -inkey privKey.pem -keyform PEM -pkeyopt rsa_padding_mode:pkcs1 -decrypt Write-Debug "OK" destroy loo_Rsa destroy loo_Bd |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.