Sample code for 30+ languages & platforms
PHP ActiveX

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 ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

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

$privKey = new COM("Chilkat.PrivateKey");
$success = $privKey->LoadAnyFormat($bd,'');
if ($success == 0) {
    print $privKey->LastErrorText . "\n";
    exit;
}

$pubKey = new COM("Chilkat.PublicKey");
$privKey->ToPublicKey($pubKey);

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

?>