(PHP ActiveX) Get Base64 Public Key from Private Key
Demonstrates how to get the public key in base64 format from a private key.
<?php
// Load a private key from base64.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.BinData')
$bd = new COM("Chilkat.BinData");
$success = $bd->AppendEncoded('MHQCA....n0Q==','base64');
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.PrivateKey')
$privKey = new COM("Chilkat.PrivateKey");
$success = $privKey->LoadAnyFormat($bd,'');
if ($success == 0) {
print $privKey->LastErrorText . "\n";
exit;
}
// pubKey is a Chilkat.PublicKey
$pubKey = $privKey->GetPublicKey();
if ($privKey->LastMethodSuccess == 0) {
print $privKey->LastErrorText . "\n";
exit;
}
$pubKeyBase64 = $pubKey->getEncoded(1,'base64');
print $pubKeyBase64 . "\n";
?>
|