Passgen
Passphrase generator that can generate arbitrary sequences from a dialect of regular expressions. It has some features for generating high-entropy memorable passphrases, such as using wordlists or generating pronounceable words from wordlists using a markov-chain monte-carlo method.
The purpose of Passgen is threefold:
- to make it easy to generate secure passphrases
- to make it easy to generate passphrases that are memorable
- to be able to accurately calculate the entropy of calculated passphrases
You can think of Passgen as evaluating regular expressions in reverse, randomly choosing anytime there are multiple options. It has some additional syntax elements (that are discussed below) for the additional features it has, such as being able to pick random words from wordlists.
Examples #
Some examples of using Passgen on the command-line. Unless you use the master-passphrase mode, every run of Passgen will yield a different, random output.
Generate arbitrary randomized passphrases from a format string. In this example, we are randomly generating sixty-four alphanumerical characters.
$ passgen '[a-zA-Z0-9]{64}'
wy08qpQHaO7jTANOwfP55W404Gkh9rjktMBCBAcKfokG0k4aoG9nmyX68pOWR0j6
Choose random words from a wordlist for XKCD-style passphrases. To use a wordlist,
we first need to tell Passgen where to find it (the -w
flag), and then we can
reference it in the pattern using the \w{name}
notation. Passgen will choose
a random word from the list.
$ passgen -w english:/usr/share/dict/words '\w{english}(-\w{english}){3}[0-9]{2,4}'
condolences-permits-oriental's-wavy67
Use a markov-chain to generate high-entropy pronounceable words. Similar to using the wordlist mode, we need to declare the word list. However, the markov-chain mode uses the letter distribution of the wordlist to generate pseudo-words rather than picking words. This results in a higher entropy, but still generates words that are pronounceable (and therefore memorable).
$ passgen -w english:/usr/share/dict/words '\m{english}(-\m{english}){3}'
una-chs-Wated-bradechughtembing
Calculates the entropy for every generated passphrase. The entropy measures how much randomness went into creating the passphrase, and therefore the amount of work an attacker would have to do to guess it. Incrementing the entropy by one doubles the amount of work necessary.
$ passgen -e -p apple2
entropy: 107.18 bits
j5KQqM-kWBomL-R6XoO9
Can define presets for commonly used passphrase patterns. Passgen comes with a set of predefined presets, but you can also configure your own in a configuration file.
$ passgen -p apple2
2k3zkR-M2h3YE-0E05Jw
Using the master-passphrase mode, it will generate deterministic passphrases for different domain-account pairs. As long as you remember the master passphrase, you can always regenerate the passphrase. This allows you to use Passgen as a kind of password manager.
$ passgen -m mysecurepass -d google.com
HpkoED-H8qanE-GWM1Mp
Syntax #
The following table is a syntax overview for the Passgen pattern description
language. An underscore (_
) represents any valid syntax element (or, in the
case of a group, any sequence of valid syntax elements).
Name | Examples | Description |
---|---|---|
Literal | abc | Emitted unchanged |
Set | [abc] ,[a-zA-Z0-9] | Consists of a list of character or character ranges (separated by - ). Randomly chooses a single character from the set. Characters from the set are weighted, if a character appears multiple times it is more likely to be picked. |
Wordlist | \w{english} | Emits random word from the wordlist named english. |
Markov | \m{english} | Emits random markov-chain generated word from the wordlist named english. |
Preset | \p{name} | Evaluates the preset name and emits its output. |
Group | (_|_) | Consists of segments of syntax elements separated by pipe (| ) characters. Randomly chooses one of the segments and emits their output. |
Optional | _? | Randomly decides to emit the element. Can be placed after any syntax element. Use a group to apply it to multiple elements. |
Repeat | _{64} _{32,48} | Repeat the preceding element n times. If a range of lengths is specified, choose a random value within the range. |
Implementations #
Initially, Passgen was implemented as a C project that evolved over time. The current implementation is written in Rust, contains less code and is faster than the legacy C implementation.
- Rust implementation
- C implementation
- Web application
- Desktop application (WIP)
- Book
- Website (old)
Goals #
- Implement web application for passgen (temporary, local, account-based, don’t store master passphrase)
- Write documentation for passgen, including benchmarks and other data
- Implement quiz application for measuring the memorability of different kinds of passphrases (numeric, alphanumeric). Control for native language.
- Distribute on mturk, lobsters, hacker news
- Write paper for passgen (topic: todo)
Notes #
- Incorporate https://seirdy.one/posts/2021/01/12/password-strength/
- Maybe add to KeePassXC/Mozilla?
Milestones #
Date | Description |
---|---|
2024-09-14 | Rust version created as passgen-rs . |
2023-01-10 | Implemented and builds WASI version of passgen-c. |
2021-11-13 | Registered https://passgen.it and hosting documentation with mkdocs. |
2021-10-10 | Implemented dynamic wordlist loading and word-choosing. |
2019-10-06 | Implemented pronounceable word generation based on a markov-chain. |
2019-07-04 | Implemented pattern parsing. |
2012-04-06 | Initial passgen repository created as password generator with fixed patterns. |