Sample code for 30+ languages & platforms
Delphi DLL

RSA Import Public Key

See more RSA Examples

Shows how to select/import a public key for RSA encryption or signature verification.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Rsa, PublicKey;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
pubKey: HCkPublicKey;
rsa: HCkRsa;

begin
success := False;

pubKey := CkPublicKey_Create();
// In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success := CkPublicKey_LoadFromFile(pubKey,'rsaKeys/myTestRsaPublic.pem');
if (success = False) then
  begin
    Memo1.Lines.Add(CkPublicKey__lastErrorText(pubKey));
    Exit;
  end;

rsa := CkRsa_Create();

// Tell RSA to use the public key.
CkRsa_UsePublicKey(rsa,pubKey);

CkPublicKey_Dispose(pubKey);
CkRsa_Dispose(rsa);

end;