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
(Unicode C) Get Base64 Public Key from Private KeyDemonstrates how to get the public key in base64 format from a private key.
#include <C_CkBinDataW.h> #include <C_CkPrivateKeyW.h> #include <C_CkPublicKeyW.h> void ChilkatSample(void) { HCkBinDataW bd; BOOL success; HCkPrivateKeyW privKey; HCkPublicKeyW pubKey; const wchar_t *pubKeyBase64; // Load a private key from base64. bd = CkBinDataW_Create(); success = CkBinDataW_AppendEncoded(bd,L"MHQCA....n0Q==",L"base64"); privKey = CkPrivateKeyW_Create(); success = CkPrivateKeyW_LoadAnyFormat(privKey,bd,L""); if (success == FALSE) { wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey)); CkBinDataW_Dispose(bd); CkPrivateKeyW_Dispose(privKey); return; } pubKey = CkPrivateKeyW_GetPublicKey(privKey); if (CkPrivateKeyW_getLastMethodSuccess(privKey) == FALSE) { wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey)); CkBinDataW_Dispose(bd); CkPrivateKeyW_Dispose(privKey); return; } pubKeyBase64 = CkPublicKeyW_getEncoded(pubKey,TRUE,L"base64"); wprintf(L"%s\n",pubKeyBase64); CkPublicKeyW_Dispose(pubKey); CkBinDataW_Dispose(bd); CkPrivateKeyW_Dispose(privKey); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.