Overview
This is a Flutter plugin that enables pub.dev/packages/cryptography_plus to use native APIs of Android, iOS, and Mac OS X.
Package was maintained by gohilla.com. Repository was moved to emz-hanauer/dart-cryptography due to lack of maintenance.
Licensed under the Apache License 2.0.
Why?
- Secure
- Operating system APIs are preferable from security point of view.
- Performant.
- Operating system APIs are up to 100 times faster than pure Dart implementations.
- Cross-platform.
- The implementations fall back to "package:cryptography" implementations when operating system APIs can't be used.
General behavior
The package is tested with cryptography_test.
This package contains two kinds of classes:
- Classes such
as FlutterChacha20
use operating system APIs in Android / iOS / Mac OS X. If the operating system does not support
the algorithm, the background implementation (such as
BackgroundChacha20
) or a pure Dart implementation (such as DartChacha20) when available. - Classes such as BackgroundChacha20 move lengthy computations to a background isolate by using compute function in Flutter SDK.
- Both compute very small inputs in the same isolate if the overhead of message passing does not make sense. For example, if you encrypt a 16 byte message, the computation is done in the same isolate.
- Too large inputs are also computed in the same isolate (because you probably should not allocate a gigabyte cross-isolate message on a mobile phone).
- We also have a queue to prevent memory exhaustion that could happen if you send lots of requests concurrently.
Getting started
In pubspec.yaml:
dependencies:
cryptography_plus: ^2.7.0
cryptography_flutter: ^2.3.2
That's it!
For API documentation, read more at pub.dev/packages/cryptography.
Behavior by algorithm
AES-GCM
FlutterAesGcm is used in Android, iOS, and Mac OS X. Our benchmarks have shown up to ~50 times better performance than DartAesGcm (the pure Dart implementation).
BackgroundAesGcm is used in Windows and Linux for inputs that are large enough.
ChaCha20-Poly1305-AEAD
FlutterChacha20 is available for Android and Apple operating systems. Our benchmarks have shown up to ~50 times better performance than DartChacha20 (the pure Dart implementation).
BackgroundChacha20 is used in Windows and Linux for inputs that are large enough.
NIST ECDH / ECDSA
FlutterEcdh and FlutterEcdsa are available for Apple operating systems.
Ed25519
FlutterEd25519 and BackgroundEd25519 are available for Apple operating systems.
X25519
FlutterX25519 and BackgroundX25519 are available for Apple operating systems.
HMAC
FlutterHmac is available for Android..
PBKDF2
FlutterPbkdf2 is available for Android. BackgroundPbkdf2 is used in Apple operating systems, Windows and Linux.
Links
Libraries
- android
- Helpers for Android.
- cryptography_flutter_plus
- An optimized version of package:cryptography.