Swift
Swift
RSA Import Private Key
See more RSA Examples
Shows how to select/import a private key for RSA signing or decryption.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
let privKey = CkoPrivateKey()!
var password: String? = "secret"
// In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success = privKey.loadAnyFormatFile(path: "rsaKeys/myTestRsaPrivate.pem", password: password)
if success == false {
print("\(privKey.lastErrorText!)")
return
}
let rsa = CkoRsa()!
// Tell the RSA object to use the private key (i.e. import the private key)
rsa.usePrivateKey(privKey: privKey)
}