Perl
Perl
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 Perl Downloads
use chilkat();
$success = 0;
# Load a private key from base64.
$bd = chilkat::CkBinData->new();
$success = $bd->AppendEncoded("MHQCA....n0Q==","base64");
$privKey = chilkat::CkPrivateKey->new();
$success = $privKey->LoadAnyFormat($bd,"");
if ($success == 0) {
print $privKey->lastErrorText() . "\r\n";
exit;
}
$pubKey = chilkat::CkPublicKey->new();
$privKey->ToPublicKey($pubKey);
$pubKeyBase64 = $pubKey->getEncoded(1,"base64");
print $pubKeyBase64 . "\r\n";