Generate memorable, word-based passwords in Elixir or from the command line. The library uses the dictionary and presets from the Ruby gem.

Elixir library

Requires Elixir 1.17 or later. Add XKPassword to your Mix dependencies.

{:xkpassword, "~> 0.1.0"}
XKPassword.generate()
XKPassword.generate(preset: :security, separator: ".")
XKPassword.generate(words: 5, min_length: 5, max_length: 8, case_transform: :capitalize)

generate/1 takes a keyword list or an atom-keyed map. Explicit options override preset defaults. Presets accept atoms or strings such as "apple-id". Use :upcase, :downcase, or :capitalize to apply the same transform to every word, or nil to randomly uppercase each word. Use separator: "" to join words directly.

PresetWordsWord lengthSeparatorCase
:xkcd (default)44–8HyphenRandom per word
:web3244–5HyphenRandom per word
:wifi64–8HyphenRandom per word
:security64–8SpaceLowercase
:apple_id34–7HyphenRandom per word

The library uses Erlang's :crypto to choose a length and then a word of that length for each position. The dictionary is embedded at compile time.

Command line

Build an executable from a checkout.

mix deps.get
mix escript.build
./xkpassword
./xkpassword --preset apple-id --separator .
./xkpassword --help

To install it on your path, run mix escript.install hex xkpassword and include ~/.mix/escripts (or $MIX_HOME/escripts) on your PATH.

The CLI reads optional YAML defaults from ~/.xkpassword, the same file used by the Ruby CLI. xkpassword --init creates a commented template. CLI flags override file settings, and both override preset defaults.

preset: security
words: 5
min_length: 4
max_length: 8
separator: "-"
case_transform: capitalize

Use --words, --min-length, and --max-length with integers. The selected range must contain dictionary words at every length.

License

MIT