Sample code for 30+ languages & platforms
Swift

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let crypt = CkoCrypt2()!

    let bdEncrypted = CkoBinData()!
    let sbPlainText = CkoStringBuilder()!

    sbPlainText.append(value: "Text to be encrypted")

    // ...
    // Set the secret key ...
    // Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
    // Set the IV if needed ...
    // ...

    crypt.charset = "utf-8"

    success = crypt.encryptSb(sbIn: sbPlainText, bdOut: bdEncrypted)
    if success == false {
        print("\(crypt.lastErrorText!)")
        return
    }


}