SkillAgentSearch skills...

CryptoSwift

CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift

Install / Use

/learn @krzyzanowskim/CryptoSwift

README

Platform

Swift support Swift Package Manager compatible Carthage compatible CocoaPods Deprecated

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.

<img alt="www.emergetools.com/" width="200" src="https://github-production-user-asset-6210df.s3.amazonaws.com/758033/256565082-a21f5ac1-ef39-4b56-a8d2-575adeb7fe55.png" />

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)

CRC32 | CRC32C | CRC16

Cipher

AES-128, AES-192, AES-256 | ChaCha20 | XChaCha20 | Rabbit | Blowfish

RSA (public-key encryption algorithm)

Encryption, Signature

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

Authenticated Encryption with Associated Data (AEAD)

Why

Why? Because I can.

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.

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 Validation aka com.apple.security.cs.disable-library-validation entitlement

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")

See: Package.swift - manual

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

View on GitHub
GitHub Stars10.6k
CategoryDevelopment
Updated53m ago
Forks1.8k

Languages

Swift

Security Score

85/100

Audited on Mar 23, 2026

No findings