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 with Modulus and ExponentDemonstrates how to RSA encrypt with a given modulus and exponent.
integer li_rc oleobject loo_Rsa string ls_Modulus string ls_Exponent oleobject loo_Xml string ls_PublicKey integer li_Success integer li_UsePrivateKey string ls_PlainText string ls_EncryptedStrBase64 // 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 // Assuming you already have a base64 modulus and exponent, // wrap it in XML like this: ls_Modulus = "qMBRpdYrAy5aMmo31NErUizh5sbweguSmh4wlK6uJEIDl+kwTlROnE34KOFExeTbJSX0WygPi+vWl0yNq7buIMUKpytossAAWut5khO3CQJxTk7G2gnEPNUUXHiExGgNrLzcSLv8YIlfVALhoRWyC67KOL+a+3taNq3h+BHeWhM=" ls_Exponent = "AQAB" loo_Xml = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml") loo_Xml.Tag = "RSAPublicKey" loo_Xml.NewChild2("Modulus",ls_Modulus) loo_Xml.NewChild2("Exponent",ls_Exponent) // Encrypt with the public key. ls_PublicKey = loo_Xml.GetXml() li_Success = loo_Rsa.ImportPublicKey(ls_PublicKey) li_UsePrivateKey = 0 ls_PlainText = "message in a bottle" loo_Rsa.EncodingMode = "base64" ls_EncryptedStrBase64 = loo_Rsa.EncryptStringENC(ls_PlainText,li_UsePrivateKey) Write-Debug ls_EncryptedStrBase64 destroy loo_Rsa destroy loo_Xml |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.