Swift
Swift
DSA Public Key PEM to DER Conversion
See more DSA Examples
Converts a DSA public key from PEM format to DER.Chilkat Swift Downloads
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 PEM public key.
var pemPublicKey: String?
pemPublicKey = dsa.loadText(path: "dsa_pub.pem")
// Import the public key PEM into the DSA object.
success = dsa.fromPublicPem(pemData: pemPublicKey)
if success != true {
print("\(dsa.lastErrorText!)")
return
}
// Write it out as a DER file:
success = dsa.toPublicDerFile(path: "dsa_pub.der")
if success != true {
print("\(dsa.lastErrorText!)")
return
}
print("Finished!")
}