1.0.0 • Published 3 years ago

niceware-eff v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

niceware-eff

This package is a fork of niceware that uses a wordlist based on the EFF's New Wordlists for Random Passphrases. Because this wordlist is much smaller, it is only useful in scenarios such where brute force attacks are minimized by some other mechanism, such as only giving attackers one chance to guess the password.

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

ParamTypeDescription
bytesBufferThe bytes to convert

niceware.passphraseToBytes(words) ⇒ Buffer

Converts a phrase back into the original byte array.

Kind: static method of niceware

ParamTypeDescription
wordsArray.<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

ParamTypeDescription
sizenumberThe 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.