Sample code for 30+ languages & platforms
Swift

RSA Import Public Key

See more RSA Examples

Shows how to select/import a public key for RSA encryption or signature verification.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let pubKey = CkoPublicKey()!
    // In all Chilkat methods expecting a path, you pass either absolute or relative paths.
    success = pubKey.load(fromFile: "rsaKeys/myTestRsaPublic.pem")
    if success == false {
        print("\(pubKey.lastErrorText!)")
        return
    }

    let rsa = CkoRsa()!

    // Tell RSA to use the public key.
    rsa.usePublicKey(pubKey: pubKey)

}