Sample code for 30+ languages & platforms
PHP ActiveX

DSA Public Key PEM to DER Conversion

See more DSA Examples

Converts a DSA public key from PEM format to DER.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$dsa = new COM("Chilkat.Dsa");

// 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 != 1) {
    print $dsa->LastErrorText . "\n";
    exit;
}

// Write it out as a DER file:
$success = $dsa->ToPublicDerFile('dsa_pub.der');
if ($success != 1) {
    print $dsa->LastErrorText . "\n";
    exit;
}

print 'Finished!' . "\n";

?>