Sample code for 30+ languages & platforms
Delphi ActiveX

Get Base64 Public Key from Private Key

See more ECC Examples

Demonstrates how to get the public key in base64 format from a private key.

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;
bd: TChilkatBinData;
privKey: TPrivateKey;
pubKey: TPublicKey;
pubKeyBase64: WideString;

begin
success := 0;

// Load a private key from base64.
bd := TChilkatBinData.Create(Self);
success := bd.AppendEncoded('MHQCA....n0Q==','base64');

privKey := TPrivateKey.Create(Self);
success := privKey.LoadAnyFormat(bd.ControlInterface,'');
if (success = 0) then
  begin
    Memo1.Lines.Add(privKey.LastErrorText);
    Exit;
  end;

pubKey := TPublicKey.Create(Self);
privKey.ToPublicKey(pubKey.ControlInterface);

pubKeyBase64 := pubKey.GetEncoded(1,'base64');
Memo1.Lines.Add(pubKeyBase64);
end;