cryptography_flutter 2.3.4 copy "cryptography_flutter: ^2.3.4" to clipboard
cryptography_flutter: ^2.3.4 copied to clipboard

Makes 'package:cryptography' use platform APIs in Android, iOS, and Mac OS X. The package can make performance up to 100 times better.

Pub Package Github Actions CI

Overview #

This is a Flutter plugin that enables pub.dev/packages/cryptography to use native APIs of Android, iOS, and Mac OS X.

Maintained by terrier989. Licensed under the Apache License 2.0.

Trade-offs of using operating system APIs #

Pros #

  • Compliant.
    • Operating system implementations of algorithms are often compliant with various compliance requirements (such as FIPS 140-2).
  • Speed.
    • For some algorithms, operating system implementations are up to 100 times faster than pure Dart implementations.

Cons #

  • Easier to inspect
    • If someone reverse engineers you application, it may be easier to inspect operating system calls than pure Dart implementations provided by package:cryptography.

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: ^2.8.1g
  cryptography_flutter: ^2.3.4

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.

37
likes
160
points
14.5k
downloads

Publisher

verified publisherdint.dev

Weekly Downloads

Makes 'package:cryptography' use platform APIs in Android, iOS, and Mac OS X. The package can make performance up to 100 times better.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

cryptography, flutter

More

Packages that depend on cryptography_flutter

Packages that implement cryptography_flutter