Delphi Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

Generate RSA Public/Private Key Pair and Export to PEM

Delphi example code showing how to generate an RSA public/private key pair and export to PEM files.

Download Chilkat RSA ActiveX

uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls,
    CHILKATCERTIFICATELib_TLB,
    CHILKATRSALib_TLB,
    OleCtrls;

...

procedure TForm1.Button1Click(Sender: TObject);
var
rsa: TChilkatRsa;
success: Integer;
publicKeyXml: String;
privateKeyXml: String;
privKey: CHILKATCERTIFICATELib_TLB.IPrivateKey;
pubKey: CHILKATCERTIFICATELib_TLB.IPublicKey;

begin
rsa := TChilkatRsa.Create(Self);

success := rsa.UnlockComponent('Anything for 30-day trial');
if (success <> 1) then
  begin
    ShowMessage('RSA component unlock failed');

  end;

//  Generate a 1024-bit key.  Chilkat RSA supports
//  key sizes ranging from 512 bits to 4096 bits.
success := rsa.GenerateKey(1024);
if (success <> 1) then
  begin
    ShowMessage(rsa.LastErrorText);

  end;

//  Keys are exported in XML format:
publicKeyXml := rsa.ExportPublicKey();
Memo1.Lines.Add(publicKeyXml);

privateKeyXml := rsa.ExportPrivateKey();
Memo1.Lines.Add(privateKeyXml);

//  Save the private key in PEM format:
privKey := TprivateKey.Create(Self).ControlInterface;
privKey.LoadXml(privateKeyXml);
privKey.SaveRsaPemFile('privateKey.pem');

//  Save the public key in PEM format:
pubKey := TpublicKey.Create(Self).ControlInterface;
pubKey.LoadXml(publicKeyXml);
pubKey.SaveOpenSslPemFile('publicKey.pem');
end;

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser