Giter Club home page Giter Club logo

niceware's Introduction

niceware

Build Status

A JS library for generating random-yet-memorable passwords, either server-side in Node or in the browser. Each word provides 16 bits of entropy, so a useful password requires at least 3 words.

Because the wordlist is of exactly size 2^16, Niceware is also useful for convert cryptographic keys and other sequences of random bytes into human-readable phrases. With Niceware, a 128-bit key is equivalent to an 8-word phrase.

Demo: https://diracdeltas.github.io/niceware/

WARNING: The wordlist has not been rigorously checked for offensive words. Use at your own risk.

Sample use cases

  • Niceware can be used to generate secure, semi-memorable, easy-to-type passphrases. A random 3-5 word phrase in Niceware is equivalent to a strong password for authentication to most online services. For instance, +8svofk0Y1o= and bacca cavort west volley are equally strong (64 bits of randomness).
  • Niceware can be used to display cryptographic key material in a way that users can easily backup or copy between devices. For instance, the 128-bit random seed used to generate a 256-bit ECC key (~equivalent to a 3072-bit RSA key) is only 8 Niceware words. With this 8-word phrase, you can reconstruct the entire public/private key pair.

Usage in Node

To install:

npm install niceware

To generate an 8-byte passphrase:

const niceware = require('niceware')

// The number of bytes must be even
const passphrase = niceware.generatePassphrase(8)

// Result: [ 'deathtrap', 'stegosaur', 'nilled', 'nonscheduled' ]

Usage in browser

To use Niceware in modern browsers, include browser/niceware.js in a script tag. Niceware is then available in the window.niceware object.

<script src='niceware.js'></script>
<script>
  const passphrase = window.niceware.generatePassphrase(8)
</script>

Niceware uses window.{crypto, msCrypto}.getRandomValues for entropy in the browser.

Docs

NOTE: When used in the browser, Buffer is replaced with window.Uint8Array.

niceware ⏏

Kind: Exported constant

niceware.bytesToPassphrase(bytes) ⇒ Array.<string>

Converts a byte array into a passphrase.

Kind: static method of niceware

Param Type Description
bytes Buffer The bytes to convert

niceware.passphraseToBytes(words) ⇒ Buffer

Converts a phrase back into the original byte array.

Kind: static method of niceware

Param Type Description
words Array.<string> The words to convert

niceware.generatePassphrase(size) ⇒ Array.<string>

Generates a random passphrase with the specified number of bytes. NOTE: size must be an even number.

Kind: static method of niceware

Param Type Description
size number The number of random bytes to use

Niceware ports

Credits

Niceware was inspired by Diceware. Its wordlist is derived from the SIL English word list. This project is based on my work on OpenPGP key backup for the Yahoo End-to-End project.

niceware's People

Contributors

adventurebeard avatar atoponce avatar awcross avatar benjaminehowe avatar dependabot[bot] avatar diracdeltas avatar grempe avatar moreati avatar peternewman avatar sa3dany avatar sts10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

niceware's Issues

Demo page

First of all, awesome tool!

But the demo page you provided may be used to generate passwords and it's not a good practice to do so. Even if it's only a static site, a good rule of thumb is avoid this altogether.

So I thought the page may show a notice saying it's only for demonstration purposes and one should never trust an online tool to generate passwords for them.

[Suggestion] Modification to allow shorter wordlists like https://www.eff.org/files/2016/09/08/eff_short_wordlist_2_0.txt

On EFF page https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases three EFF wordlists are published, and the short list https://www.eff.org/files/2016/09/08/eff_short_wordlist_2_0.txt offers some nice features, however this list contains only 1296 words

Finally, we're publishing one more short list [.txt] which with a few additional features making the words easy to type:
Each word has a unique three-character prefix. This means that future software could auto-complete words in the passphrase after the user has typed the first three characters
All words are at least an edit distance of 3 apart. This means that future software could correct any single typo in the user's passphrase (and in many cases more than one typo).

Please allow me to suggest a modification of niceware which would allow to make use of such a short wordlist.

Python port of Niceware

I've done a Niceware for Python port . Before I publicise it or upload it to PyPI do you have any objections/queries/changes you'd like me to address/fix?

I've included a test suite based closely on yours, and it passes. Phrases generated/converted by the Python port are interchangeable with phrases from your implementation. There's no command line interface yet, but that's my next priority. The code is Python 2.x and 3.x agnostic.

Stylistic changes include:

  • lowercase_with_underscores instead of camelCase
  • bytes_to_passphrase() accepts any sequnce that bytearray can accept, rather than only accepting e.g. bytes objects.

Error: window.niceware is undefined

Running locally, when trying demo 2 to convert a hex to a nice phrase, or demo 3 to convert a phrase to hex, the following error is returned: Error: window.niceware is undefined. This is running in Firefox 80.0 on Debian unstable

update deps

github shows a security warning for cached-path-relative which is required by browserify

Offensive words

There are some offensive / objectionable words in the wordlist.

Although some are not exclusively bad words, they do appear unprofessional in generated passwords...

Words - Dike - Dildo - Dildoe - Prick

niceware command in python-niceware

I'm experimenting with adding a command line interface to python-niceware. e.g.

$ python -m niceware
herein crestal chumping philoprogenitive frontal pressman vibrancy obnoxiety
$ python -m niceware --count 2 --length 5
gaoling rainmaking mutate spangling nonconvertible
slag simultaneously tazza intermediary sacrosanct

The current implementation also installs a script called niceware. I'm conscious that this encroaches on a global namespace. It might clash with any future CLI to your original implementation. Would you prefer I leave this script out of python-niceware, or change the name of the command, to e.g. nicewarepy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.