PHP Requires Chilkat v11.0.0+
PHP
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 Downloads
<?php
use Chilkat2\BinData;
use Chilkat2\PrivateKey;
use Chilkat2\PublicKey;
// Load a private key from base64.
$bd = new BinData();
$bd->AppendEncoded('MHQCA....n0Q==', 'base64');
$privKey = new PrivateKey();
try {
$privKey->LoadAnyFormat($bd, '');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
$pubKey = new PublicKey();
$privKey->ToPublicKey($pubKey);
$pubKeyBase64 = $pubKey->GetEncoded(true, 'base64');
echo $pubKeyBase64, "\n";