![]() |
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
(VBScript) 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 fso, outFile Set fso = CreateObject("Scripting.FileSystemObject") 'Create a Unicode (utf-16) output text file. Set outFile = fso.CreateTextFile("output.txt", True, True) success = 0 ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. set privKey = CreateObject("Chilkat.PrivateKey") ' Load the private key from an RSA PEM file: success = privKey.LoadPemFile("private.pem") If (success = 0) Then outFile.WriteLine(privKey.LastErrorText) WScript.Quit End If set rsa = CreateObject("Chilkat.Rsa") success = rsa.UsePrivateKey(privKey) If (success = 0) Then outFile.WriteLine(rsa.LastErrorText) WScript.Quit End If strData = "secret" set bd = CreateObject("Chilkat.BinData") success = bd.AppendString(strData,"utf-8") success = rsa.SignRawBd(bd) hexSig = bd.GetEncoded("hex") outFile.WriteLine(hexSig) ' Recover the data using the corresponding public key: set pubKey = CreateObject("Chilkat.PublicKey") ' Load the public key from a PEM file: success = pubKey.LoadFromFile("public.pem") If (success = 0) Then outFile.WriteLine(pubKey.LastErrorText) WScript.Quit End If set rsa2 = CreateObject("Chilkat.Rsa") success = rsa2.UsePublicKey(pubKey) If (success = 0) Then outFile.WriteLine(rsa2.LastErrorText) WScript.Quit End If set bd2 = CreateObject("Chilkat.BinData") success = bd2.AppendEncoded(hexSig,"hex") ' Recover the original data. success = rsa2.VerifyRawBd(bd2) If (success = 0) Then outFile.WriteLine(rsa2.LastErrorText) WScript.Quit End If originalData = bd2.GetString("utf-8") outFile.WriteLine(originalData) outFile.Close |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.