Sample code for 30+ languages & platforms
PHP Extension

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 PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

// Load a private key from base64.
$bd = new CkBinData();
$success = $bd->AppendEncoded('MHQCA....n0Q==','base64');

$privKey = new CkPrivateKey();
$success = $privKey->LoadAnyFormat($bd,'');
if ($success == false) {
    print $privKey->lastErrorText() . "\n";
    exit;
}

$pubKey = new CkPublicKey();
$privKey->ToPublicKey($pubKey);

$pubKeyBase64 = $pubKey->getEncoded(true,'base64');
print $pubKeyBase64 . "\n";

?>