Sample code for 30+ languages & platforms
JavaScript

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.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

// Load a private key from base64.
var bd = new CkBinData();
success = bd.AppendEncoded("MHQCA....n0Q==","base64");

var privKey = new CkPrivateKey();
success = privKey.LoadAnyFormat(bd,"");
if (success == false) {
    console.log(privKey.LastErrorText);
    return;
}

var pubKey = new CkPublicKey();
privKey.ToPublicKey(pubKey);

var pubKeyBase64 = pubKey.GetEncoded(true,"base64");
console.log(pubKeyBase64);