CryptoSwift
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift
Install / Use
/learn @krzyzanowskim/CryptoSwiftREADME
CryptoSwift
Crypto related functions and helpers for Swift implemented in Swift. (#PureSwift)
Note: The main branch follows the latest currently released version of Swift. If you need an earlier version for an older version of Swift, specify its version in your Podfile or use the code on the branch for that version. Older branches are unsupported. Check versions for details.
Requirements | Features | Contribution | Installation | Swift versions | How-to | Author | License | Changelog
Support & Sponsors
The financial sustainability of the project is possible thanks to the ongoing contributions from our GitHub Sponsors
Premium Sponsors
Emerge Tools is a suite of revolutionary products designed to supercharge mobile apps and the teams that build them.
Requirements
Good mood
Features
- Easy to use
- Convenient extensions for String and Data
- Support for incremental updates (stream, ...)
- iOS, Android, macOS, AppleTV, watchOS, Linux support
Hash (Digest)
MD5 | SHA1 | SHA2-224 | SHA2-256 | SHA2-384 | SHA2-512 | SHA3
Cyclic Redundancy Check (CRC)
Cipher
AES-128, AES-192, AES-256 | ChaCha20 | XChaCha20 | Rabbit | Blowfish
RSA (public-key encryption algorithm)
Message authenticators
Poly1305 | HMAC (MD5, SHA1, SHA256) | CMAC | CBC-MAC
Cipher mode of operation
- Electronic codebook (ECB)
- Cipher-block chaining (CBC)
- Propagating Cipher Block Chaining (PCBC)
- Cipher feedback (CFB)
- Output Feedback (OFB)
- Counter Mode (CTR)
- Galois/Counter Mode (GCM)
- Counter with Cipher Block Chaining-Message Authentication Code (CCM)
- OCB Authenticated-Encryption Algorithm (OCB)
Password-Based Key Derivation Function
- PBKDF1 (Password-Based Key Derivation Function 1)
- PBKDF2 (Password-Based Key Derivation Function 2)
- HKDF (HMAC-based Extract-and-Expand Key Derivation Function)
- Scrypt (The scrypt Password-Based Key Derivation Function)
Data padding
- PKCS#5
- EMSA-PKCS1-v1_5 (Encoding Method for Signature)
- EME-PCKS1-v1_5 (Encoding Method for Encryption)
- PKCS#7
- Zero padding
- ISO78164
- ISO10126
- No padding
Authenticated Encryption with Associated Data (AEAD)
Why
How do I get involved?
You want to help, great! Go ahead and fork our repo, make your changes and send us a pull request.
Contribution
Check out CONTRIBUTING.md for more information on how to help with CryptoSwift.
- If you found a bug, open a discussion.
- If you have a feature request, open a discussion.
Installation
Hardened Runtime (macOS) and Xcode
Binary CryptoSwift.xcframework (Used by Swift Package Manager package integration) won't load properly in your app if the app uses Sign to Run Locally Signing Certificate with Hardened Runtime enabled. It is possible to setup Xcode like this. To solve the problem you have two options:
- Use proper Signing Certificate, eg. Development <- this is the proper action
- Use
Disable Library Validationakacom.apple.security.cs.disable-library-validationentitlement
Xcode Project
To install CryptoSwift, add it as a submodule to your project (on the top level project directory):
git submodule add https://github.com/krzyzanowskim/CryptoSwift.git
It is recommended to enable Whole-Module Optimization to gain better performance. Non-optimized build results in significantly worse performance.
Swift Package Manager
You can use Swift Package Manager and specify dependency in Package.swift by adding this:
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.9.0")
Notice: Swift Package Manager uses debug configuration for debug Xcode build, that may result in significant (up to x10000) worse performance. Performance characteristic is different in Release build. To overcome this problem, consider embed CryptoSwift.xcframework described below.
Carthage
You can use Carthage. Specify in Cartfile:
github "krzyzanowskim/CryptoSwift"
Run carthage to build the framework and drag the built CryptoSwift.framework into your Xcode project. Follow build instructions. Common issues.
CocoaPods
Note: CocoaPods is deprecated and no longer recommended for new projects. Use Swift Package Manager or Carthage instead.
You can use CocoaPods.
pod 'CryptoSwift', '~> 1.8.4'
Bear in mind that CocoaPods will build CryptoSwift without Whole-Module Optimization that may impact performance. You can change it manually after installation, or use cocoapods-wholemodule plugin.
XCFramework
XCFrameworks require Xcode 11 or later and they can be integrated similarly to how we’re used to integrating the .framework format.
Please use script scripts/build-framework.sh to generate binary CryptoSwift.xcframework archive that you can use as a dependency in Xcode.
CryptoSwift.xcframework is a Release (Optimized) binary that offer best available Swift code performance.
<img width="320" alt="Screen Shot 2020-10-27 at 00 06 32" src="https://user-images.githubusercontent.com/758033/97240586-f0878280-17ee-11eb-9119-e5a960417d04.png">Embedded Framework
Embedded frameworks require a minimum deployment target of iOS 11.0 or macOS Sier
Related Skills
node-connect
330.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
81.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
330.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
81.4kCommit, push, and open a PR
