Gist: mkpassphrase

Published on 2022-09-02

I've always liked passphrases because they're easy to remember and in cases when I don't need to remember them, they're a lot easier to type in manually when I look them up in my password manager of choice.

One problem with them though is that a lot of the world has created password requirements around weak passwords and as such require me to put capitals, numbers and special characters in a lot of my passwords - a long password consisting of only lowercase characters doesn't pass these checks regardless of how long it is.

There is a passphrase generator in Bitwarden, but it's based on the Diceware EFF long wordlist, which at 7776 words isn't terribly long. It also can't include special characters so we need to manually select one if our passphrase is going to pass any password requirements, and since humans are terrible at choosing things at random I prefer my computer to do that for me.

Luckily, I know how to make my computer do my bidding, so I wrote a short Python script that generates a passphrase from an Aspell dictionary, capitalizes one word and separates the words with random numbers and special characters. The default language is Swedish, and to only use words that are between 4 and 10 characters in length. You can change these via options - or you can just change the defaults in the code.

Here's a a few example runs (don't use these as your password):

$ mkpassphrase
kryssad#Bekymret1lekstugor

$ mkpassphrase -p
78339
akvarie8Vises@äntrade

$ mkpassphrase -l en
forenoons$Subbranch6rorting

$ mkpassphrase -n 5
Bokstavlig#tenarna8skrymteri8alkemin@fristaden

$ mkpassphrase --min-length 1 --max-length 100 -p
119591
underrättelser&Sparrade9samspråkades