CryptoSwift implements standard cryptographic algorithms in Swift for hashing, ciphers, message authentication, and key derivation. It integrates via Swift Package Manager and targets Apple platforms, Linux, and Android.
Overview
CryptoSwift is a Swift library that collects cryptographic building blocks for application and protocol work. It is written entirely in Swift and exposes convenient helpers for String, Data, and Array types, including streaming and incremental update APIs.
The library covers digest functions such as MD5, SHA family variants, and SHA-3, plus CRC helpers. Cipher support includes AES key sizes, ChaCha20 variants, RSA encryption and signatures, and numerous block modes including GCM and CCM for authenticated encryption.
Message authenticators include Poly1305, HMAC, and CMAC. Password-based key derivation covers PBKDF, HKDF, and scrypt. Documentation in the project recommends AEAD modes and modern hashes for new designs while treating older algorithms as legacy interoperability options.
Installation is primarily through Swift Package Manager, with optional local XCFramework builds for manual Xcode integration. Apple platform deployment targets and Linux and Android exercise in CI are documented for compatibility planning.
Key features
- AES and ChaCha20 ciphers
- SHA and SHA-3 digests
- AES-GCM and AEAD modes
- HMAC and Poly1305 MACs
- RSA encrypt and sign
- Streaming incremental crypto APIs
- String and Data convenience helpers
- Swift Package Manager distribution
Use cases
- Swift app encryption
- Protocol and token signing
- Password-based key derivation
- Replacing CommonCrypto in Swift