Sample code for 30+ languages & platforms
Swift

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let cert = CkoCert()!

    success = cert.loadPfxFile(path: "c:/pfx_files/my.pfx", password: "password")
    if success != true {
        print("\(cert.lastErrorText!)")
        return
    }

    let decrypt = CkoCrypt2()!
    decrypt.cryptAlgorithm = "pki"

    success = decrypt.setDecryptCert(cert: cert)
    if success != true {
        print("\(decrypt.lastErrorText!)")
        return
    }

    let bd = CkoBinData()!
    success = bd.loadFile(path: "c:/someDir/pkcs7_encrypted.dat")

    success = decrypt.decryptBd(bd: bd)
    if success != true {
        print("\(decrypt.lastErrorText!)")
        return
    }

    // bd contains the decrypted content.

}