Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -ADemonstrates how to duplicate the creation of an RSA signature produced by this OpenSSL command: openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CHILKATCERTIFICATELib_TLB, CHILKATRSALib_TLB, OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject); var pkey: CHILKATCERTIFICATELib_TLB.IPrivateKey; success: Integer; pkeyXml: String; rsa: TChilkatRsa; strData: String; base64Sig: String; begin pkey := TprivateKey.Create(Self).ControlInterface; // Load the private key from an RSA PEM file: pkey.LoadPemFile('myKey.pem'); // Get the private key in XML format: pkeyXml := pkey.GetXml(); rsa := TChilkatRsa.Create(Self); // Any string argument automatically begins the 30-day trial. success := rsa.UnlockComponent('30-day trial'); if (success <> 1) then begin Memo1.Lines.Add(rsa.LastErrorText); Exit; end; // Import the private key into the RSA component: success := rsa.ImportPrivateKey(pkeyXml); if (success <> 1) then begin Memo1.Lines.Add(rsa.LastErrorText); Exit; end; // OpenSSL uses BigEndian byte ordering: rsa.LittleEndian := 0; // The resulting signature will be a Base64 string: rsa.EncodingMode := 'base64'; // For simplicity, we're not loading // the data to be signed from a file. We are instead simply // using a literal string value. strData := 'This is the text to be signed.'; // Hash the input using MD5, and then sign the hash: // Other valid hash algorithm choices are "md2" and "sha-1". base64Sig := rsa.SignStringENC(strData,'md5'); Memo1.Lines.Add(base64Sig); ShowMessage('Success!'); end; |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.