Sample code for 30+ languages & platforms
Perl

DSA Public Key PEM to DER Conversion

See more DSA Examples

Converts a DSA public key from PEM format to DER.

Chilkat Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

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

my $dsa = Chilkat2::Dsa->new;

# Load a PEM public key.
my $pemPublicKey = $dsa->LoadText('dsa_pub.pem');
# Import the public key PEM into the DSA object.
my $success = $dsa->FromPublicPem($pemPublicKey);
if (!$success) {
    print $dsa->LastErrorText, "\n";
    exit;
}

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

print "Finished!\n";