Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(Delphi DLL) Get Base64 Public Key from Private KeyDemonstrates how to get the public key in base64 format from a private key.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, BinData, PrivateKey, PublicKey; ... procedure TForm1.Button1Click(Sender: TObject); var bd: HCkBinData; success: Boolean; privKey: HCkPrivateKey; pubKey: HCkPublicKey; pubKeyBase64: PWideChar; begin // 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 := CkPrivateKey_GetPublicKey(privKey); if (CkPrivateKey_getLastMethodSuccess(privKey) = False) then begin Memo1.Lines.Add(CkPrivateKey__lastErrorText(privKey)); Exit; end; pubKeyBase64 := CkPublicKey__getEncoded(pubKey,True,'base64'); Memo1.Lines.Add(pubKeyBase64); CkPublicKey_Dispose(pubKey); CkBinData_Dispose(bd); CkPrivateKey_Dispose(privKey); end; |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.