Node.js
Node.js
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 Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// Load a private key from base64.
var bd = new chilkat.BinData();
success = bd.AppendEncoded("MHQCA....n0Q==","base64");
var privKey = new chilkat.PrivateKey();
success = privKey.LoadAnyFormat(bd,"");
if (success == false) {
console.log(privKey.LastErrorText);
return;
}
var pubKey = new chilkat.PublicKey();
privKey.ToPublicKey(pubKey);
var pubKeyBase64 = pubKey.GetEncoded(true,"base64");
console.log(pubKeyBase64);
}
chilkatExample();