Loading repository data…
Loading repository data…
krzyzanowskim / repository
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift
Pure Swift cryptographic primitives and utilities for Swift. (#PureSwift)
Note: The current release line builds with Swift 5.6 and newer toolchains. If you need an older compiler, use the matching legacy branch listed in Swift version support. Older branches are not actively maintained.
Requirements | Features | Recommended Defaults | Contribution | Installation | Swift Version Support | How-to | Author | License | Changelog
The financial sustainability of the project is possible thanks to the ongoing contributions from our GitHub Sponsors
None
Good mood
String, Data, and Array<UInt8>MD5 | SHA1 | SHA2-224 | SHA2-256 | SHA2-384 | SHA2-512 | SHA3
AES-128, AES-192, AES-256 | ChaCha20 | XChaCha20 | Rabbit | Blowfish
Poly1305 | HMAC (MD5, SHA1, SHA256) | CMAC | CBC-MAC
You want to help, great! Go ahead and fork our repo, make your changes and send us a pull request.
Check out CONTRIBUTING.md for more information on how to help with CryptoSwift.
CryptoSwift is primarily distributed as source through Swift Package Manager.
Add the package dependency:
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.10.0")
]
Then add the product to the target that uses it:
.target(
name: "MyTarget",
dependencies: [
.product(name: "CryptoSwift", package: "CryptoSwift")
]
)
If you profile crypto-heavy workloads from Xcode, compare Debug and Release builds before drawing conclusions. Debug builds can be dramatically slower than optimized Release builds.
If you prefer a prebuilt optimized binary for manual Xcode integration, build CryptoSwift.xcframework locally:
./scripts/build-framework.sh
The generated CryptoSwift.xcframework is an alternative to source-based Swift Package Manager integration. It is not used by the package defined in Package.swift.
If you embed the prebuilt CryptoSwift.xcframework in a hardened macOS app, library validation can prevent the binary from loading when the app is signed with Sign to Run Locally.
To avoid that, use one of these options:
Disable Library Validation (com.apple.security.cs.disable-library-validation) for the app.To vendor CryptoSwift directly in an Xcode project, add it as a submodule from the top-level project directory:
git submodule add https://github.com/krzyzanowskim/CryptoSwift.git
Enable Whole-Module Optimization for best performance. Non-optimized builds of crypto-heavy code are significantly slower.
You can use Carthage for existing projects.
Specify in Cartfile:
github "krzyzanowskim/CryptoSwift"
Run carthage to build the framework and drag the built CryptoSwift.framework into your Xcode project. Follow the Carthage getting started guide. See common issues if the build fails.
Note: CocoaPods is deprecated for new CryptoSwift integrations. Prefer Swift Package Manager. Keep CocoaPods only when you need it for an existing project.
You can still use CocoaPods.
pod 'CryptoSwift', '~> 1.10.0'
CocoaPods builds may need manual optimization settings if performance matters. You can adjust them after installation, or use the cocoapods-wholemodule plugin.
Embedded frameworks require a minimum deployment target of iOS 11.0 or macOS 10.13. Drag CryptoSwift.xcodeproj into your Xcode project, add the appropriate framework as a dependency, then embed CryptoSwift.framework in your app target.

Sometimes the embedded framework option is not available automatically. In that case, add a new build phase for the target.

In the project, you'll find single scheme for all platforms:
Legacy compiler branches: