/memorable-password-generator

Generates memorable passwords with short words and numeral sequences, with a number of configurable options. Similar output to what you'd find on an ISP-provided WiFi router.

Primary LanguageJavaScript

memorable-password-generator

Generates memorable passwords with short words and numeral sequences, with a number of configurable options.

Install

npm install --save memorable-password-generator

Usage

import { createMemorablePassword } from 'memorable-password-generator'

(async () => {
  const dictionary = ['single','dimensional','array','of','strings']

  let password = createMemorablePassword(dictionary)
  console.log(password) // single87STRINGS

})()

Dictionary

createMemorablePassword expects a single-dimensional array of strings as a dictionary, which allows you to compose that argument from any function, method, or API call that returns exactly that. Or, you can hard-code it—you do you.

Options

const options = {
    upperCase: 'alternate', // alternate (default), none, all, alternate, random
    pattern: 'wdw', // any combination of 'w' and 'd', representing words and digits, respectively
    maxWordLength: null, // Specifying an integer will filter the dictionary down to words whose length does not exceed this value
    maxNumber: 100 // This value is an upper bound on the numerals generated by 'd' pattern segments, and will indicate how many zeroes to left-pad on those numerals
}

Examples

Each example assumes the following dictionary:

const dictionary = ['one','two','buckle','my','shoe','three','four','shut','the','door','five','six','pick','up','sticks','seven','eight','lay','them','straight','nine','ten','start','again']

Default options

pw = await createMemorablePassword(dictionary) // straight32SEVEN

Patterns

pw = await createMemorablePassword(dictionary, { pattern: 'wdwdw' }) // door75THE80TWO
pw = await createMemorablePassword(dictionary, { pattern: 'ddwwddww' }) //0288theFIVE3603twoTEN

Uppercase

pw = await createMemorablePassword(dictionary, { upperCase: 'alternate' }) // my82FOUR
pw = await createMemorablePassword(dictionary, { upperCase: 'random', pattern: 'wdwdw' }) // again91SHUT78THREE
pw = await createMemorablePassword(dictionary, { upperCase: 'all' }) // TEN45EIGHT
pw = await createMemorablePassword(dictionary, { upperCase: 'none' }) // three21shoe

MaxWordLength

pw = await createMemorablePassword(dictionary, { maxWordLength: 2 }) // my33UP
pw = await createMemorablePassword(dictionary, { maxWordLength: 3 }) // THE03two
pw = await createMemorablePassword(dictionary, { maxWordLength: 4 }) // FOUR94lay

MaxNumber

pw = await createMemorablePassword(dictionary, { maxNumber: 100 }) // ONE03shoe
pw = await createMemorablePassword(dictionary, { maxNumber: 1000 }) // five036DOOR
pw = await createMemorablePassword(dictionary, { maxNumber: 10000 }) // sticks0891START