(PHP Extension) Convert DSA Public Key DER to PEM
Converts a DSA public key from DER format to PEM.
<?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 DER public key.
$success = $dsa->FromPublicDerFile('dsa_pub.der');
if ($success != true) {
print $dsa->lastErrorText() . "\n";
exit;
}
// Save the public key to PEM:
$pemStr = $dsa->toPublicPem();
$success = $dsa->SaveText($pemStr,'dsa_pub.pem');
if ($success != true) {
print $dsa->lastErrorText() . "\n";
exit;
}
print 'Finished!' . "\n";
?>
|