(Delphi ActiveX) RSA Import Private Key
Shows how to select/import a private key for RSA signing or decryption.
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
privKey: TPrivateKey;
password: WideString;
success: Integer;
rsa: TChilkatRsa;
begin
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.ImportPrivateKeyObj(privKey.ControlInterface);
end;
|