Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Get Base64 Public Key from Private KeyDemonstrates how to get the public key in base64 format from a private key.
#include <C_CkBinData.h> #include <C_CkPrivateKey.h> #include <C_CkPublicKey.h> void ChilkatSample(void) { HCkBinData bd; BOOL success; HCkPrivateKey privKey; HCkPublicKey pubKey; const char *pubKeyBase64; // 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) { printf("%s\n",CkPrivateKey_lastErrorText(privKey)); CkBinData_Dispose(bd); CkPrivateKey_Dispose(privKey); return; } pubKey = CkPrivateKey_GetPublicKey(privKey); if (CkPrivateKey_getLastMethodSuccess(privKey) == FALSE) { printf("%s\n",CkPrivateKey_lastErrorText(privKey)); CkBinData_Dispose(bd); CkPrivateKey_Dispose(privKey); return; } pubKeyBase64 = CkPublicKey_getEncoded(pubKey,TRUE,"base64"); printf("%s\n",pubKeyBase64); CkPublicKey_Dispose(pubKey); CkBinData_Dispose(bd); CkPrivateKey_Dispose(privKey); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.