(Delphi DLL) RSA Import Public Key
Shows how to select/import a public key for RSA encryption or signature verification.
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
pubKey: HCkPublicKey;
success: Boolean;
rsa: HCkRsa;
begin
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_ImportPublicKeyObj(rsa,pubKey);
CkPublicKey_Dispose(pubKey);
CkRsa_Dispose(rsa);
end;
|