Sample code for 30+ languages & platforms
JavaScript

DSA Public Key PEM to DER Conversion

See more DSA Examples

Converts a DSA public key from PEM format to DER.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var dsa = new CkDsa();

// Load a PEM public key.
var pemPublicKey;
pemPublicKey = dsa.LoadText("dsa_pub.pem");
// Import the public key PEM into the DSA object.
success = dsa.FromPublicPem(pemPublicKey);
if (success !== true) {
    console.log(dsa.LastErrorText);
    return;
}

// Write it out as a DER file:
success = dsa.ToPublicDerFile("dsa_pub.der");
if (success !== true) {
    console.log(dsa.LastErrorText);
    return;
}

console.log("Finished!");