Sample code for 30+ languages & platforms
React Native Requires Chilkat v11.0.0+

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 React Native Downloads

React Native
import { BinData, PrivateKey, PublicKey } from '@chilkat/react-native'

function chilkatExample() {
  // Load a private key from base64.
  const bd = new BinData();
  bd.appendEncoded('MHQCA....n0Q==', 'base64');

  const privKey = new PrivateKey();
  try {
    privKey.loadAnyFormat(bd, '');
  } catch {
    console.log(privKey.lastErrorText);
    return;
  }

  const pubKey = new PublicKey();
  privKey.toPublicKey(pubKey);

  const pubKeyBase64 = pubKey.getEncoded(true, 'base64');
  console.log(pubKeyBase64);
}