Sample code for 30+ languages & platforms
Java

Convert DSA Public Key DER to PEM

See more DSA Examples

Converts a DSA public key from DER format to PEM.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Dsa;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Dsa dsa = new Dsa();

        // Load a DER public key.
        try {
            dsa.fromPublicDerFile("dsa_pub.der");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        // Save the public key to PEM:
        String pemStr = dsa.toPublicPem();
        try {
            dsa.saveText(pemStr, "dsa_pub.pem");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("Finished!");
    }
}