Sample code for 30+ languages & platforms
Perl 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 Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

# Load a private key from base64.
my $bd = Chilkat2::BinData->new;
my $success = $bd->AppendEncoded('MHQCA....n0Q==', 'base64');

my $privKey = Chilkat2::PrivateKey->new;
$success = $privKey->LoadAnyFormat($bd, '');
if (!$success) {
    print $privKey->LastErrorText, "\n";
    exit;
}

my $pubKey = Chilkat2::PublicKey->new;
$privKey->ToPublicKey($pubKey);

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