CryptoSwift 是 Swift 实现的 Crypto 相关的函数。
// convenience setup tuple let setup = (key: keyData, iv: ivData) // encrypt if let encrypted = Cipher.ChaCha20(setup).encrypt(dataToEncrypt) { // decrypt if let decrypted = Cipher.ChaCha20(setup).decrypt(encrypted) { // validate result if (encrypted.isEqual(decrypted)) { print("Decryption failed!") } } }