chacha20 1.0.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 46

Introduction #

A pure Dart implementation of Chacha20, a popular stream encryption algorithm. Tests utilize examples from RFC 7539, an implementation guide by the the Internet Research Task Force.

Performance on a recent Intel CPU + Dart VM is:

  • About 100MB/s when message size is 1 MB.
  • About 50MB/s when message size is 100 bytes.

Licensed under the Apache License 2.0.

A simple example #

import 'dart:typed_data';

void main() {
    // ----------
    // Parameters
    // ----------
    // 256-bit (secret) key
    var key = Chacha20.randomKey();
    
    // 96-bit (non-secret) nonce
    var nonce = new Uint8List(12);
    
    // -------------
    // Convert bytes
    // -------------
    // Initialize
    final chacha20 = new Chacha20();
    chacha20.initialize(key: key, nonce: nonce);
    
    // convert message [1,2,3]
    print(chacha20.convert([1,2,3]));
    
    // ---------------------------------------
    // Convert more messages with the same key
    // ---------------------------------------
    // It's important that we don't re-use the same (key, nonce) combination.
    // So let's increment the nonce for the next message.
    nonce = Chacha20.incrementNonceBytes(nonce);
    
    // ------------------
    // Converting streams
    // ------------------
    // Let's say we have the following stream
    final stream = new Stream<List<int>>.fromIterable([[1,2,3], [5], [7,11]]);
    
    // Initialize
    chacha20.initialize(key: key, nonce: nonce);
    
    // Convert chunk-by-chunk.
    // 'keyStreamIndex' is incremented when you advance in the stream.
    final convertedStream = stream.map((chunk) {
      return chacha20.convert(chunk);
    });
    
}

1.0.1 #

  • Removed non-inlined version.

1.0.0 #

  • Initial release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  chacha20: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:chacha20/chacha20.dart';
  
Version Uploaded Documentation Archive
1.0.2 Feb 21, 2019 Go to the documentation of chacha20 1.0.2 Download chacha20 1.0.2 archive
1.0.0 Feb 5, 2019 Go to the documentation of chacha20 1.0.0 Download chacha20 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
4
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

We analyzed this package on Apr 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:chacha20/chacha20.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and chacha20.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
meta ^1.0.0 1.1.7
Dev dependencies
benchmark_harness ^1.0.5
pedantic ^1.0.0
test ^1.4.0