Generate XKCD-style Passwords
Perl Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Perl program to generate XKCD-style passwords


I want there to be NO barriers to using this code, so I am releasing it to the public domain. But "public domain" does not have an internationally agreed upon definition, so I use CC0:

Copyright 2017 Steven Ford and licensed "public domain" style under CC0: CC0

To the extent possible under law, the contributors to this project have waived all copyright and related or neighboring rights to this work. In other words, you can use this code for any purpose without any restrictions. This work is published from: United States. The project home is

To contact me, Steve Ford, project owner, you can find my email address at Can't see it? Keep looking.


XKCD had an excellent comic -- -- which proposed a style of password generation consisting of randomly selecting 4 words from a list of ~2000 common words. The result is a password which is more secure and easier to remember than most common methods of password creation.

The pgen program downloads a list of common english words and randomly selects some for a password. I used the program to produce some mildly-interesting results in my blog.

Here are the interesting features of the program:

  • It starts with a set of 3000 words published by Education First and filters it by word length.

  • It can either use Perl's internal pseudo-random number generator (useful for experimentation and statistics gathering), or it can get random numbers from which makes the resulting password properly secure.

You can get help by entering:

    ./pgen -h

Important: if you plan to actually use the passwords you generate, use "-r"! Here's why. and

Also included are two shell scripts that fetch lists of common words off the Internet. goes to Wiktionary to get 2000 words, and goes to Education First to get 3000 words.

These shell scripts are not needed since I included code in the Perl program to fetch the Education First list. (The reason I do this is that the material on Education First's site is copyrighted, so I can't just snag a copy of their word list without permission.)