Skip to content

Instantly share code, notes, and snippets.

@jasontbradshaw
Last active December 4, 2015 17:37
Show Gist options
  • Save jasontbradshaw/62958c491207de0ad9de to your computer and use it in GitHub Desktop.
Save jasontbradshaw/62958c491207de0ad9de to your computer and use it in GitHub Desktop.
Generate a Diceware-style password list.
#!/usr/bin/env bash
# This script takes a list of words and turns it into a 10-sided-die version of a
# Diceware list. It:
# * Reads a list of words
# * Removes long words and those with non-ASCII characters, for ease-of-use
# * Randomly orders them
# * Takes the first 10,000 (for use with 10-sided dice)
# * Sorts them nicely
# * Numbers the lines appropriately
# * Saves them to a new file
WORDS='/usr/share/dict/usa'
OUT='passwords.txt'
cat "${WORDS}" | \
grep -P '^[a-zA-Z0-9]+$' | \
sort -R | \
head -n 10000 | \
sort | \
nl --number-format=rz --starting-line-number=0 --number-width=4 --number-separator=' ' | \
> "${OUT}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment