This is a Flutter plugin that enables pub.dev/packages/cryptography to use native APIs of Android, iOS, and Mac OS X.
- Operating system APIs are preferable from security point of view.
- Operating system APIs are up to 100 times faster than pure Dart implementations.
- 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
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.
dependencies: cryptography: ^2.7.0 cryptography_flutter: ^2.3.2
For API documentation, read more at pub.dev/packages/cryptography.
Behavior by algorithm
BackgroundAesGcm is used in Windows and Linux for inputs that are large enough.
BackgroundChacha20 is used in Windows and Linux for inputs that are large enough.
NIST ECDH / ECDSA
FlutterHmac is available for Android..