![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Duplicating OpenSSL rsautl (creating RSA signatures)Demonstrates how to duplicate OpenSSL rsautil RSA signatures. The Chilkat RSA component's methods for creating RSA signatures (SignBytes, SignBytesENC, SignString, and SignStringENC) are very different from OpenSSL's rsautl command. First, we'll explain what Chilkat's signing methods do, and then what OpenSSL's rsautl does. New signing methods have been added to Chilkat RSA to duplicate OpenSSL rsautl: OpenSslSignBytes, OpenSslSignBytesENC, OpenSslSignString, and OpenSslSignStringENC.
Here's what Chilkat's RSA Sign* methods do:
OpenSSL rsautl is very different. Here's what it does:
Note: This example requires Chilkat v11.0.0 or greater.
LOCAL lnSuccess LOCAL loPrivKey LOCAL loRsa LOCAL lcStrData LOCAL loBd LOCAL lcHexSig LOCAL loPubKey LOCAL loRsa2 LOCAL loBd2 LOCAL lcOriginalData lnSuccess = 0 * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loPrivKey = CreateObject('Chilkat.PrivateKey') * Load the private key from an RSA PEM file: lnSuccess = loPrivKey.LoadPemFile("private.pem") IF (lnSuccess = 0) THEN ? loPrivKey.LastErrorText RELEASE loPrivKey CANCEL ENDIF loRsa = CreateObject('Chilkat.Rsa') lnSuccess = loRsa.UsePrivateKey(loPrivKey) IF (lnSuccess = 0) THEN ? loRsa.LastErrorText RELEASE loPrivKey RELEASE loRsa CANCEL ENDIF lcStrData = "secret" loBd = CreateObject('Chilkat.BinData') loBd.AppendString(lcStrData,"utf-8") lnSuccess = loRsa.SignRawBd(loBd) lcHexSig = loBd.GetEncoded("hex") ? lcHexSig * Recover the data using the corresponding public key: loPubKey = CreateObject('Chilkat.PublicKey') * Load the public key from a PEM file: lnSuccess = loPubKey.LoadFromFile("public.pem") IF (lnSuccess = 0) THEN ? loPubKey.LastErrorText RELEASE loPrivKey RELEASE loRsa RELEASE loBd RELEASE loPubKey CANCEL ENDIF loRsa2 = CreateObject('Chilkat.Rsa') lnSuccess = loRsa2.UsePublicKey(loPubKey) IF (lnSuccess = 0) THEN ? loRsa2.LastErrorText RELEASE loPrivKey RELEASE loRsa RELEASE loBd RELEASE loPubKey RELEASE loRsa2 CANCEL ENDIF loBd2 = CreateObject('Chilkat.BinData') loBd2.AppendEncoded(lcHexSig,"hex") * Recover the original data. lnSuccess = loRsa2.VerifyRawBd(loBd2) IF (lnSuccess = 0) THEN ? loRsa2.LastErrorText RELEASE loPrivKey RELEASE loRsa RELEASE loBd RELEASE loPubKey RELEASE loRsa2 RELEASE loBd2 CANCEL ENDIF lcOriginalData = loBd2.GetString("utf-8") ? lcOriginalData RELEASE loPrivKey RELEASE loRsa RELEASE loBd RELEASE loPubKey RELEASE loRsa2 RELEASE loBd2 |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.