C++
C++
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 C++ Downloads
#include <CkBinData.h>
#include <CkPrivateKey.h>
#include <CkPublicKey.h>
void ChilkatSample(void)
{
bool success = false;
// Load a private key from base64.
CkBinData bd;
success = bd.AppendEncoded("MHQCA....n0Q==","base64");
CkPrivateKey privKey;
success = privKey.LoadAnyFormat(bd,"");
if (success == false) {
std::cout << privKey.lastErrorText() << "\r\n";
return;
}
CkPublicKey pubKey;
privKey.ToPublicKey(pubKey);
const char *pubKeyBase64 = pubKey.getEncoded(true,"base64");
std::cout << pubKeyBase64 << "\r\n";
}