npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eff-diceware-passphrase

v3.0.0

Published

Generate a cryptographically random password from EFF's improved Diceware word list

Downloads

71

Readme

eff-diceware-passphrase

Generate a cryptographically random password from EFF's improved Diceware word list

In July 2016, EFF release a more user friendly Diceware list in the article Deep Dive: EFF's New Wordlists for Random Passphrases.

A Diceware list is a dictionary of 6^5 == 7776 words, making it possible to use 5 normal dice as a source of entropy. Since the dictionary is fixed, it is possible to reason about how much entropy each new word (token) contributes to the passphrase; lg(6^5) ≈ 12.9 bits.

However in this module we use the CSRNG builtin to sample n words from the dictionary, and securely shuffle them. The sampling is without replacement as to not confuse the user in case of repeated words. This lowers the entropy by a negligible amount.

Usage

var generatePassphrase = require('eff-diceware-passphrase')

generatePassphrase(8) // List of 8 words
generatePassphrase.entropy(100) // List of words with at least 100 bits of entropy

You can also get the JSON encoded dictionary directly:

var dictionary = require('eff-diceware-passphrase/wordlist.json')

Bundle size considerations

Be aware that the JSON encoded Diceware list is just over 25kb gzipped. Making a minimal Browserify bundle with optimisations will yield a bundle of 34.6kb.

$ browserify -g uglifyify -g unassertify example.js | uglifyjs -cm | gzip - | wc -c
34593

API

generatePassphrase(count)

Generate a list of count words, randomly shuffled and without replacement.

const arr = generatePassphrase.words

Sorted array of all words in the Diceware list

const arr = generatePassphrase.entropy(minimum)

Convenience function for generating a password with at least mimimum bits of entropy.

const i = generatePassphrase.indexOf(word)

Like Array.prototype.indexOf. Returns the index in generatePassphrase.words or -1 if not found.

const bool = generatePassphrase.includes(word)

Like Array.prototype.includes. Returns true if part of generatePassphrase.words or false if not found.

const i = generatePassphrase.indexOfPrefix(prefix)

Returns the index of the first occurrence of the prefix, or the end of the wordlist if no prefixes match. Can be used to slice the list for eg. autocomplete

Install

npm install eff-diceware-passphrase

License

ISC