Java
Chilkat2 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
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!");
}
}