Skip to content

Commit 2f3de6d

Browse files
committed
Improves documentation.
1 parent f7d1127 commit 2f3de6d

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

cryptography/README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ Any feedback, issue reports, or pull requests are appreciated!
2727
# Getting started
2828

2929
If you use Flutter, it's recommended (but not necessarily) that you also import our sibling package
30-
[cryptography_flutter](https://pub.dev/packages/cryptography_flutter), which improves performance
31-
by using operating system APIs.
30+
[cryptography_flutter](https://pub.dev/packages/cryptography_flutter), which delegates calls to
31+
Android / iOS / Mac OS X operating system APIs whenever possible.
3232

3333
In _pubspec.yaml_:
3434
```yaml
3535
dependencies:
36-
cryptography: ^2.5.0
37-
cryptography_flutter: ^2.3.0 # Remove if you don't use Flutter
36+
cryptography: ^2.5.1
37+
cryptography_flutter: ^2.3.1 # Remove if you don't use Flutter
3838
```
3939
4040
You are ready to go!
@@ -207,7 +207,8 @@ faster because this package automatically uses Web Crypto API.
207207
208208
## Random number generators
209209
210-
We continue to use the old good `Random.secure()` as the default random number in all APIs.
210+
We use Dart SDK [Random.secure()](https://api.dart.dev/stable/3.1.0/dart-math/Random/Random.secure.html)
211+
as the default random number in all APIs.
211212
212213
If you do want much faster cryptographically reasonably strong random numbers, this package contains
213214
[SecureRandom.fast](https://pub.dev/documentation/cryptography/latest/cryptography/SecureRandom/fast.html).
@@ -353,17 +354,14 @@ authentication code).
353354
When you decrypt, you need the _SecretBox_ and the secret key.
354355

355356
In the following example, we encrypt a message
356-
with [AesCtr](https://pub.dev/documentation/cryptography/latest/cryptography/AesCtr-class.html)
357-
and a [Hmac](https://pub.dev/documentation/cryptography/latest/cryptography/Hmac-class.html) message
358-
authentication code that uses [Sha256](https://pub.dev/documentation/cryptography/latest/cryptography/Sha256-class.html)
359-
hash algorithm:
357+
with [AesGcm](https://pub.dev/documentation/cryptography/latest/cryptography/AesGcm-class.html):
360358
```dart
361359
import 'dart:convert';
362360
import 'package:cryptography/cryptography.dart';
363361
364362
Future<void> main() async {
365363
// Choose the cipher
366-
final algorithm = AesCtr(macAlgorithm: Hmac.sha256());
364+
final algorithm = AesGcm.with256bits();
367365
368366
// Generate a random secret key.
369367
final secretKey = await algorithm.newSecretKey();

cryptography/lib/src/cryptography/mac_algorithm.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,28 @@ import 'package:cryptography/dart.dart';
2121

2222
/// A Message Authentication Code (MAC) algorithm.
2323
///
24+
/// You can compute a [Mac] by calling [calculateMac] or [newMacSink].
25+
///
2426
/// ## Available algorithms
2527
/// * [Hmac]
26-
/// * [MacAlgorithm.empty]
2728
/// * [Poly1305]
29+
///
30+
/// ## Not using MAC?
31+
///
32+
/// If are sure you don't need a MAC, you can use [MacAlgorithm.empty]:
33+
/// ```
34+
/// final example = ChaCha20(macAlgorithm: MacAlgorithm.empty);
35+
/// ```
2836
abstract class MacAlgorithm {
2937
/// MAC algorithm that always returns [Mac.empty].
3038
static const MacAlgorithm empty = _EmptyMacAlgorithm();
3139

3240
const MacAlgorithm();
3341

42+
/// Number of bytes in key stream used to initialize the MAC algorithm.
43+
///
44+
/// In [Chacha20.poly1305Aead], the first block of the ChaCha20 stream is used
45+
/// as the Poly1305 key (thus [keyStreamUsed] is 64).
3446
int get keyStreamUsed => 0;
3547

3648
/// Number of bytes in the message authentication code.
@@ -39,6 +51,7 @@ abstract class MacAlgorithm {
3951
/// Whether the algorithm supports Associated Authenticated Data (AAD).
4052
bool get supportsAad => false;
4153

54+
/// Whether the algorithm supports key stream index.
4255
bool get supportsKeyStreamIndex => keyStreamUsed == 0;
4356

4457
/// Calculates message authentication code.

cryptography_flutter/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ In _pubspec.yaml_:
4949

5050
```yaml
5151
dependencies:
52-
cryptography: ^2.5.0
53-
cryptography_flutter: ^2.3.0
52+
cryptography: ^2.5.1
53+
cryptography_flutter: ^2.3.1
5454
```
5555
5656
That's it!

jwk/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ Maintained by Gohilla. Licensed under the [Apache License 2.0](LICENSE).
1111
In _pubspec.yaml_
1212
```yaml
1313
dependencies:
14-
cryptography: ^2.4.0
15-
jwk: ^0.2.2
16-
``
14+
cryptography: ^2.5.1
15+
jwk: ^0.2.3
1716
```
1817
1918
# Examples

0 commit comments

Comments
 (0)