(PHP Extension) DSA Public Key PEM to DER Conversion
Converts a DSA public key from PEM format to DER.
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$dsa = new CkDsa();
// Load a PEM public key.
$pemPublicKey = $dsa->loadText('dsa_pub.pem');
// Import the public key PEM into the DSA object.
$success = $dsa->FromPublicPem($pemPublicKey);
if ($success != true) {
print $dsa->lastErrorText() . "\n";
exit;
}
// Write it out as a DER file:
$success = $dsa->ToPublicDerFile('dsa_pub.der');
if ($success != true) {
print $dsa->lastErrorText() . "\n";
exit;
}
print 'Finished!' . "\n";
?>
|