This is a Flutter plugin that enables pub.dev/packages/cryptography to use native APIs of Android, iOS, and Mac OS X.
Maintained by gohilla.com. Licensed under the Apache License 2.0.
- 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.
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.
In pubspec.yaml:
dependencies:
cryptography: ^2.7.0
cryptography_flutter: ^2.3.2
That's it!
For API documentation, read more at pub.dev/packages/cryptography.
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.
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.
FlutterEcdh and FlutterEcdsa are available for Apple operating systems.
FlutterEd25519 and BackgroundEd25519 are available for Apple operating systems.
FlutterX25519 and BackgroundX25519 are available for Apple operating systems.
FlutterHmac is available for Android..
FlutterPbkdf2 is available for Android. BackgroundPbkdf2 is used in Apple operating systems, Windows and Linux.