Sample code for 30+ languages & platforms
Perl

Convert DSA Public Key DER to PEM

See more DSA Examples

Converts a DSA public key from DER format to PEM.

Chilkat Perl Downloads

Perl
use chilkat();

$success = 0;

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

$dsa = chilkat::CkDsa->new();

# Load a DER public key.
$success = $dsa->FromPublicDerFile("dsa_pub.der");
if ($success != 1) {
    print $dsa->lastErrorText() . "\r\n";
    exit;
}

# Save the public key to PEM:
$pemStr = $dsa->toPublicPem();
$success = $dsa->SaveText($pemStr,"dsa_pub.pem");
if ($success != 1) {
    print $dsa->lastErrorText() . "\r\n";
    exit;
}

print "Finished!" . "\r\n";