Sample code for 30+ languages & platforms
Delphi ActiveX

RSA Import Private Key

See more RSA Examples

Shows how to select/import a private key for RSA signing or decryption.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
privKey: TPrivateKey;
password: WideString;
rsa: TChilkatRsa;

begin
success := 0;

privKey := TPrivateKey.Create(Self);
password := 'secret';
// In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success := privKey.LoadAnyFormatFile('rsaKeys/myTestRsaPrivate.pem',password);
if (success = 0) then
  begin
    Memo1.Lines.Add(privKey.LastErrorText);
    Exit;
  end;

rsa := TChilkatRsa.Create(Self);

// Tell the RSA object to use the private key (i.e. import the private key)
rsa.UsePrivateKey(privKey.ControlInterface);
end;