dart_wordlists 1.0.2

dart_wordlists #

Pub Package CircleCI

A library for passphrase word lists. Inspired by Diceware and others

Created from templates made available by Stagehand under a BSD-style license.

Usage #

generate pgp mnemonic from byte array #

import 'package:dart_wordlists/dart_wordlists.dart';

main(List<String> arguments) async {
  PgpMnemonic pgpWords = new PgpMnemonic();
  await pgpWords.init();

  if (arguments.isEmpty) {
    print("You must supply a hex string (whitespace separation a-ok!)");
  } else {
    print(pgpWords.toPhraseFromHex(arguments.join(' ')).join(' '));
  }
}

running the example:

foo@bar$ pub run example/pgp_words.dart a2b4 ff5a 21a9
rebirth politeness Zulu existence blackjack passenger

foo@bar$ pub run example/pgp_unwords.dart rebirth politeness Zulu existence blackjack passenger
a2b4ff5a21a9

word list selection w/ collection sampler #

A simple usage example:

import 'package:dart_wordlists/dart_wordlists.dart';
import 'package:dart_collection_sampler/dart_collection_sampler.dart';

import 'package:args/args.dart';


main(List<String> arguments) async {
  var argParser = new ArgParser()
    ..addOption("num", abbr: "n",
        help: "items to pick from rest of command line",
        defaultsTo: "6");

  var results = argParser.parse(arguments);

  sample(int.parse(results["num"]));
}

sample(int sampleSize) async {
  var loader = new WordlistLoader();

  var sampler = new CollectionSampler();

  var wordlists = [
    Wordlist.bip39_en,
    Wordlist.bip39_zh_CW,
    Wordlist.diceware_beale_en,
    Wordlist.eff_large_en
  ];
  for (final wl in wordlists) {
    var meta = loader.findMetadata(wl);
    print(loader.findMetadata(wl));

    var words = await loader.findLoader(wl).load();
    print(words);

    print ("sample: ${sampler.pickN(words, sampleSize)}");
    print ("\n");
  }
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Similar projects #

Credits #

Diceware #

diceware is a concept invented by Arnold G. Reinhold, Cambridge, Massachusetts USA.

The English Diceware Wordlists used with this programme are licensed by Arnold G. Reinhold (files wordlists/wordlist_en_orig.asc, wordlists/wordlist_en.txt) under the Creative Commons CC-BY 3.0 license (see http://creativecommons.org/licenses/by/3.0/).

"Diceware" is a trademark of A G Reinhold.

EFF #

The EFF wordlist (file wordlsts/wordlist_en_eff.txt) is licensed by the Electronic Frontier Foundation under the Creative Commons CC-BY 3.0 US license (see https://creativecommons.org/licenses/by/3.0/us/).

See EFF's New Wordlists for Random Passphrases

BIP39 #

See BIP39

Changelog #

1.0.2 #

  • update to latest readme/deps

1.0.1 #

  • make code more idiomatic

1.0.0 #

  • start fixing analysis issues

0.2.4 #

  • fix package desc

0.2.3 #

  • update deps

0.2.2 #

0.2.0 #

  • upgrade to dart 2

0.1.1 #

  • add unit test for entropy

0.1.0 #

  • change diceware-style parser to return Map<String,String>
  • add method to calculate entropy per word from wordlist

0.0.2 #

  • in CLI example, don't select unique words

0.0.1 #

  • Initial version

example/main.dart

import 'package:args/args.dart';
import 'package:dart_collection_sampler/dart_collection_sampler.dart';
import 'package:dart_wordlists/dart_wordlists.dart';

void main(List<String> arguments) async {
  var argParser = ArgParser()
    ..addOption("num",
        abbr: "n", help: "words to pick from wordlist", defaultsTo: "6");

  var results = argParser.parse(arguments);

  sample(int.parse(results["num"]));
}

void sample(int sampleSize) async {
  var loader = WordlistLoader();

  var sampler = CollectionSampler();

  var wordlists = [
    Wordlist.bip39_zh_CW,
    Wordlist.diceware_beale_en,
    Wordlist.eff_large_en,
    Wordlist.eff_short_v1_en,
  ];
  for (final wl in wordlists) {
    var meta = loader.findMetadata(wl);
    print(loader.findMetadata(wl));

    var words = await loader.findLoader(wl).load();
    print(words);

    print("sample: ${sampler.pickN(words, sampleSize, unique: false)}");
    print("\n");
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  dart_wordlists: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dart_wordlists/dart_wordlists.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:dart_wordlists/dart_wordlists.dart with components: isolate.

Health suggestions

Format lib/dart_wordlists.dart.

Run dartfmt to format lib/dart_wordlists.dart.

Format lib/src/pgp_mnemonic.dart.

Run dartfmt to format lib/src/pgp_mnemonic.dart.

Format lib/src/wordlist_parser.dart.

Run dartfmt to format lib/src/wordlist_parser.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
convert ^2.1.1 2.1.1
memoize ^2.0.0 2.0.0
quiver >=2.0.0 <3.0.0 2.0.5
resource >=2.1.5 <3.0.0 2.1.6
Transitive dependencies
charcode 1.1.2
matcher 0.12.5
meta 1.1.7
path 1.6.4
stack_trace 1.9.3
typed_data 1.1.6
Dev dependencies
args ^1.5.2
dart_collection_sampler >=1.0.7
mockito ^4.1.0
test ^1.6.4