Sample code for 30+ languages & platforms
Swift

Convert DSA Public Key DER to PEM

See more DSA Examples

Converts a DSA public key from DER format to PEM.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

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

    let dsa = CkoDsa()!

    // Load a DER public key.
    success = dsa.fromPublicDerFile(path: "dsa_pub.der")
    if success != true {
        print("\(dsa.lastErrorText!)")
        return
    }

    var pemStr: String?

    // Save the public key to PEM:
    pemStr = dsa.toPublicPem()
    success = dsa.saveText(strToSave: pemStr, path: "dsa_pub.pem")
    if success != true {
        print("\(dsa.lastErrorText!)")
        return
    }

    print("Finished!")

}