Markov chains

Made-up words that can be pronounced, and carry more entropy than real ones.

Random characters are strong, but hard to remember. Words from a wordlist are easy to remember, but it takes many of them to make a strong passphrase. Passgen has a third way, which sits between the two: it can make up words that sound like real ones.

$ passgen '\m{english}( \m{english}){3}'
cal agraphilicity dissively unsthesiller

The examples on this page use a wordlist called english, which is defined in the configuration:

[wordlists]
english = "/usr/share/dict/words"

How it works

Passgen reads the wordlist, and counts which letters follow which. For every sequence of three letters, it remembers which letters come after it in the wordlist, and how often. This table is called a Markov chain.

To make up a word, Passgen starts with nothing and adds one letter at a time. Every letter is chosen at random, but letters that often follow the previous three in the wordlist are more likely. The end of the word is chosen the same way, so the words have no fixed length.

The result follows the habits of the language. It can be pronounced like a word of that language, but in most cases it is not one.

Why use it

More entropy than words

A word from a wordlist of 479,823 words has 18.87 bits of entropy. A made-up word from the same wordlist has 30.85 bits on average, at the same length. You need fewer words for the same strength.

This table compares different ways to get a passphrase of about 80 bits:

KindPatternEntropyLengthBits per character
Lowercase letters[a-z]{18}84.6 bits184.70
Proquints\p{proquint80}80.0 bits292.76
Made-up words\m{english}( \m{english}){2}92.8 bits on average303.09
Words\w{english}( \w{english}){4}94.4 bits511.86
Words, EFF wordlist\w{eff-large}( \w{eff-large}){6}90.5 bits551.65

Three made-up words do what takes five to seven real ones, in a bit more than half the characters.

Pronounceable

A made-up word is built like a real one, so you can say it. That makes it much easier to remember, to read out and to type than random characters. Compare:

ybvhtqsielignwpxka
betten mame doubters altantical

The downside: the entropy varies

Every word in a wordlist is equally likely, so every passphrase of four words has the same entropy. This is not the case for made-up words. Some of them follow the most common paths through the chain, and are much more likely than others. The entropy that Passgen reports is that of the passphrase it generated, and it is different every time:

$ passgen --entropy --amount 3 '\m{english}( \m{english}){3}'
entropy: 100.78 bits
cal agraphilicity dissively unsthesiller
entropy: 112.08 bits
canoa dynamarrangly imme hexamauch
entropy: 88.47 bits
betten mame doubters altantical

For this pattern, half of all passphrases have more than 117 bits. But one in twenty has less than 76 bits, and the weakest of 100,000 had 48.5 bits.

Throwing away the weak ones is safe, as long as you do not throw away almost everything. For the pattern above, it costs less than one bit:

You ask forPassphrases that have itWhat you are guaranteed
80 bits92%79.89 bits
90 bits83%89.73 bits
100 bits72%99.52 bits
110 bits59%109.24 bits
120 bits47%118.92 bits

Even if you only ask for 80 bits, that is more than the 75.49 bits of four real words from the same wordlist.

Chain length

The length of the chain is how many letters back Passgen looks when it chooses the next one. It is 3 by default. To change it, add a length from 1 to 8 after the name of the wordlist, as in \m{english:2}.

A short chain only knows which letter tends to follow which. Its words have a lot of entropy, but are often hard to pronounce. A long chain has few letters to choose from at every step, and mostly finds its way back to the words it was built from:

LengthExampleEntropy of a wordWords that are real
1Ys dr ckielris jata ouend39.29 bits25%
2suromanace panninin vowlegent35.11 bits20%
3waulously sobraciousmation pnei30.85 bits18%
4tune toothdrakes Austing hema26.23 bits23%
5excising windies generaloperity22.29 bits42%
8nonpossession antiprotease tanagroid19.13 bits92%

The entropy is the average for a single word. With a length of 8, nine out of ten words are words of the wordlist, and the entropy is barely above the 18.87 bits of choosing one of them directly. The length of the words does not change with the length of the chain. It is about nine letters on average, as in the wordlist.

The default of 3 is a good choice for most uses. A length of 4 gives words that are a little easier to pronounce, and entropy that varies less. You need one more word for the same strength.

Choosing a wordlist

A chain can only be as good as the wordlist it learns from.

  • Use a large wordlist. The chain needs a lot of text to pick up how the words of a language are built. The EFF wordlists that come with Passgen have 7,776 words or fewer. They are made for choosing words from, and are too small for this.
  • The numbers depend on the wordlist. The numbers on this page were measured with /usr/share/dict/words as it comes with Fedora, which has 479,823 words. Other systems have other words in this file, and give other numbers.
  • What is in the wordlist comes out. If the wordlist has names or words with a hyphen, the made-up words can have capital letters and hyphens too.
  • Any language works. Passgen fully supports Unicode, so the wordlist can be in any language, and the words will sound like that language.

With a master passphrase

What a pattern with Markov chains generates may change from one version of Passgen to the next. It also depends on every word of the wordlist. Avoid these patterns in master-passphrase mode, where a passphrase has to come out the same every time.