![]() |
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 Basic 6.0) 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.
Dim success As Long success = 0 ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim privKey As New PrivateKey ' Load the private key from an RSA PEM file: success = privKey.LoadPemFile("private.pem") If (success = 0) Then Debug.Print privKey.LastErrorText Exit Sub End If Dim rsa As New ChilkatRsa success = rsa.UsePrivateKey(privKey) If (success = 0) Then Debug.Print rsa.LastErrorText Exit Sub End If Dim strData As String strData = "secret" Dim bd As New ChilkatBinData success = bd.AppendString(strData,"utf-8") success = rsa.SignRawBd(bd) Dim hexSig As String hexSig = bd.GetEncoded("hex") Debug.Print hexSig ' Recover the data using the corresponding public key: Dim pubKey As New PublicKey ' Load the public key from a PEM file: success = pubKey.LoadFromFile("public.pem") If (success = 0) Then Debug.Print pubKey.LastErrorText Exit Sub End If Dim rsa2 As New ChilkatRsa success = rsa2.UsePublicKey(pubKey) If (success = 0) Then Debug.Print rsa2.LastErrorText Exit Sub End If Dim bd2 As New ChilkatBinData success = bd2.AppendEncoded(hexSig,"hex") ' Recover the original data. success = rsa2.VerifyRawBd(bd2) If (success = 0) Then Debug.Print rsa2.LastErrorText Exit Sub End If Dim originalData As String originalData = bd2.GetString("utf-8") Debug.Print originalData |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.