![]() |
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
(Classic ASP) 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.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% success = 0 ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. set privKey = Server.CreateObject("Chilkat.PrivateKey") ' Load the private key from an RSA PEM file: success = privKey.LoadPemFile("private.pem") If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( privKey.LastErrorText) & "</pre>" Response.End End If set rsa = Server.CreateObject("Chilkat.Rsa") success = rsa.UsePrivateKey(privKey) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( rsa.LastErrorText) & "</pre>" Response.End End If strData = "secret" set bd = Server.CreateObject("Chilkat.BinData") success = bd.AppendString(strData,"utf-8") success = rsa.SignRawBd(bd) hexSig = bd.GetEncoded("hex") Response.Write "<pre>" & Server.HTMLEncode( hexSig) & "</pre>" ' Recover the data using the corresponding public key: set pubKey = Server.CreateObject("Chilkat.PublicKey") ' Load the public key from a PEM file: success = pubKey.LoadFromFile("public.pem") If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( pubKey.LastErrorText) & "</pre>" Response.End End If set rsa2 = Server.CreateObject("Chilkat.Rsa") success = rsa2.UsePublicKey(pubKey) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( rsa2.LastErrorText) & "</pre>" Response.End End If set bd2 = Server.CreateObject("Chilkat.BinData") success = bd2.AppendEncoded(hexSig,"hex") ' Recover the original data. success = rsa2.VerifyRawBd(bd2) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( rsa2.LastErrorText) & "</pre>" Response.End End If originalData = bd2.GetString("utf-8") Response.Write "<pre>" & Server.HTMLEncode( originalData) & "</pre>" %> </body> </html> |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.