Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

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 DLL Downloads

Delphi DLL
var
success: Boolean;
bd: HCkBinData;
privKey: HCkPrivateKey;
pubKey: HCkPublicKey;
pubKeyBase64: PWideChar;

begin
success := False;

//  Load a private key from base64.
bd := CkBinData_Create();
success := CkBinData_AppendEncoded(bd,'MHQCA....n0Q==','base64');

privKey := CkPrivateKey_Create();
success := CkPrivateKey_LoadAnyFormat(privKey,bd,'');
if (success = False) then
  begin
    Memo1.Lines.Add(CkPrivateKey__lastErrorText(privKey));
    Exit;
  end;

pubKey := CkPublicKey_Create();
CkPrivateKey_ToPublicKey(privKey,pubKey);

pubKeyBase64 := CkPublicKey__getEncoded(pubKey,True,'base64');
Memo1.Lines.Add(pubKeyBase64);

CkBinData_Dispose(bd);
CkPrivateKey_Dispose(privKey);
CkPublicKey_Dispose(pubKey);