11[ ![ Pub Package] ( https://img.shields.io/pub/v/cryptography_flutter.svg )] ( https://pub.dev/packages/cryptography_flutter )
2- [ ![ Github Actions CI] ( https://github.com/dint-dev/cryptography/workflows/Dart%20CI/badge.svg )] ( https://github.com/dint-dev/cryptography/actions?query=workflow%3A%22Dart+CI%22 )
2+ [ ![ Github Actions CI] ( https://github.com/dint-dev/cryptography/workflows/Dart%20CI/badge.svg )] ( https://github.com/dint-dev/cryptography/actions )
33
44# Overview
55
66This is a version of the package [ cryptography] ( https://pub.dev/packages/cryptography ) that
77optimizes performance of some cryptographic algorithms by using native APIs of Android, iOS, and
88Mac OS X. You must use asynchronous methods to get the performance boost.
99
10- Maintained by Gohilla Ltd . Licensed under the [ Apache License 2.0] ( LICENSE ) .
10+ Maintained by Gohilla. Licensed under the [ Apache License 2.0] ( LICENSE ) .
1111
12- ## Optimized algorithms
13- ### In Android
14- * [ AesCbc()] ( https://pub.dev/documentation/cryptography/latest/cryptography/AesCbc-class.html )
15- * [ AesCtr()] ( https://pub.dev/documentation/cryptography/latest/cryptography/AesCtr-class.html )
16- * [ AesGcm()] ( https://pub.dev/documentation/cryptography/latest/cryptography/AesGcm-class.html )
17- * [ Chacha20.poly1305()] ( https://pub.dev/documentation/cryptography/latest/cryptography/Chacha20-class.html )
12+ ## General behavior
13+ This package contains two kinds of classes:
14+ * Classes such as [ FlutterChacha20] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterChacha20-class.html )
15+ use operating system APIs in Android / iOS / Mac OS X. If the operating system does not support
16+ the algorithm, the background implementation (such as ` BackgroundChacha20 ` ) or a pure Dart
17+ implementation (such as [ DartChacha20] ( https://pub.dev/documentation/cryptography/latest/cryptography.dart/DartChacha20-class.html ) )
18+ when available.
19+ * Classes such as [ BackgroundChacha20] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundChacha20-class.html )
20+ move the computation away from the UI isolate using [ compute] ( https://api.flutter.dev/flutter/foundation/compute-constant.html )
21+ ("package: flutter /foundation.dart").
1822
19- ### In iOS and Mac OS X
20- * [ AesGcm()] ( https://pub.dev/documentation/cryptography/latest/cryptography/AesGcm-class.html )
21- * [ Chacha20.poly1305()] ( https://pub.dev/documentation/cryptography/latest/cryptography/Chacha20-class.html )
22-
23- ## Links
24- * [ Github project] ( https://github.com/dint-dev/cryptography )
25- * [ Issue tracker] ( https://github.com/dint-dev/cryptography/issues )
26- * [ Pub package] ( https://pub.dev/packages/cryptography_flutter )
27- * [ API reference] ( https://pub.dev/documentation/cryptography_flutter/latest/ )
23+ Both compute very small inputs in the same isolate if the overhead of message passing does not
24+ make sense. For example, if you encrypt a 16 byte message, the computation is done in the same
25+ isolate. Too large inputs are also computed in the same isolate (because you probably should not
26+ allocate a gigabyte cross-isolate message on a mobile phone). We also have a queue to prevent memory
27+ exhaustion that could happen if you send lots of requests concurrently (something we observed
28+ during testing).
2829
2930# Getting started
3031In _ pubspec.yaml_ :
3132``` yaml
3233dependencies :
33- cryptography : ^2.0.5
34- cryptography_flutter : ^2.0.2
34+ cryptography : ^2.1.0
35+ cryptography_flutter : ^2.1.0
3536` ` `
3637
3738Then just use:
3839` ` ` dart
3940import 'package:cryptography_flutter/cryptography_flutter.dart';
4041
4142void main() {
42- // Enable Flutter cryptography
43+ // Enable use of operating system APIs.
44+ // This is an optional performance optimization.
4345 FlutterCryptography.enable();
4446
4547 // ....
@@ -48,6 +50,61 @@ void main() {
4850
4951For APIs, read documentation for [ package: cryptography ] ( https://pub.dev/packages/cryptography ) .
5052
53+ # Optimizations by platform
54+ ## In iOS and Mac OS X
55+ Calling ` FlutterCryptography.enable() ` enables:
56+ * [ FlutterAesGcm] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterAesGcm-class.html )
57+ * Our benchmarks have shown up to ~ 50 times better performance.
58+ * [ FlutterChacha20] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterChacha20-class.html )
59+ * Our benchmarks have shown up to ~ 10 times better performance.
60+ * [ FlutterEd25519] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterEd25519-class.html )
61+ * Our benchmarks have shown up to ~ 10 times better performance.
62+ * [ FlutterX25519] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterX25519-class.html )
63+ * Our benchmarks have shown up to ~ 10 times better performance.
64+
65+ By default, maximum input size is 100 MB.
66+
67+ ## In Android
68+ We have observe problems with some Android devices. Therefore we have disabled some optimizations
69+ until we have time to investigate the problems.
70+
71+ Calling ` FlutterCryptography.enable() ` enables:
72+ * [ FlutterAesGcm] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterAesGcm-class.html )
73+ * Our benchmarks have shown up to ~ 50 times better performance.
74+ * [ FlutterChacha20] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterChacha20-class.html )
75+ * Our benchmarks have shown up to ~ 10 times better performance.
76+ * [ BackgroundEd25519] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundEd25519-class.html )
77+ * [ BackgroundX25519] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundX25519-class.html )
78+
79+ By default, maximum input size is 20 MB because of memory allocation crashes we observed during
80+ testing.
81+
82+ ## In other platforms
83+ In browsers, nothing is changed.
84+
85+ In Windows, Linux, and other platforms:
86+ * [ BackgroundAesGcm] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundAesGcm-class.html )
87+ * [ BackgroundChacha20] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundChacha20-class.html )
88+ * [ BackgroundEd25519] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundEd25519-class.html )
89+ * [ BackgroundX25519] ( https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundX25519-class.html )
90+
91+ ## Links
92+ * [ Github project] ( https://github.com/dint-dev/cryptography )
93+ * [ Issue tracker] ( https://github.com/dint-dev/cryptography/issues )
94+ * [ Pub package] ( https://pub.dev/packages/cryptography_flutter )
95+ * [ API reference] ( https://pub.dev/documentation/cryptography_flutter/latest/ )
96+
97+
5198# Contributing?
52- Test the plugin by running integration tests in
53- _ cryptography_flutter/example/_ (see README in the directory).
99+ This is how you run the tests:
100+ ```
101+ ./tool/test.sh
102+ ```
103+
104+ Alternatively:
105+ ```
106+ flutter test --no-pub
107+ cd example
108+ flutter test --no-pub integration_test
109+ ```
110+
0 commit comments