Skip to main content

Generate secure multiword passphrases, inspired by XKCD

Project description

xkcd-phrase

A flexible and scriptable password generator which generates strong passphrases, inspired by XKCD 936.

$ xkcd-phrase
Move Barbed Unplug Huskiness 

This password generator is inspired by XKCD 936 and the version provided by Adam Birds With the original code from redacted/xkcd-password-generator.. The defaults have been configured in a way to give this tool the most compatibility out of the box with passphrase requirements and the flexibility to adjust for site specific requirements. The defaults provide:

  • A phrase containing 4 words between 4 and 9 characters (The default wordfile eff-long only contains words between 4 and 9 characters).
  • The first letter of each word is capitalized.
  • A seperator for human readability.

This allows the phrase generator to provide phrases by default which will be strong, easy to remember, difficult to brute-force and still pass the usual requirements of at least one upper-case letter, one lower-case letter and a special character.

Install

xkcd-phrase can easily be installed with the following command:

pip install xkcd-phrase

or manually by:

python -m pip install <path><package>

Source

The source code can be found here.

Requirements

Python 3 (Version 3.8 or later).

Running xkcd_phrase

xkcd-phrase can be called with no arguments with an output using the default wordfile and settings.

$ xkcd-phrase
> Spiffy Deceit Unease Pushover

The default settings return a single phrase made up of 4 words each having: its first letter capitalized and spaces between the words for readability.

It can also be called with a mixture of multiple arguments for example:

$ xkcd-phrase -d _ -c 5 --min 5 --max 7 --numeric-char-num 4 --numeric-char-append
Cause_Resale_Moody_Arise6814
Suggest_Bundle_Cruelly_Suggest4674
Sleeve_Resort_Plastic_Drool5351
Hazily_Skimmed_Islamic_Gigolo6475
Salvage_Sphinx_Tightly_Banter9381

This will return:

  • -d _ words joined by _.
  • -c 5 5 passwords to choose from.
  • --min 5 --max 7 words between 5 and 7 characters long.
  • --numeric-char-num 4 Include 4 numerical characters in the passphrase.
  • --numeric-char-append Include the numerics on the end of the passphrase.
$ xkcd-phrase -V -n 6 --numeric-char-num 2 --special-char-num 2
The total possible number of symbol choices in the phrase is
77 possible symbols comprising:
        52 alphabetic characters
        10 numeric characters
        15 special characters

The phrase length is 53 with the entropy of the phrase is calculated as:
        log2(possible_symb (77) ^ phrase_len (53)) = 332.14

The phrase is: I)licit0y Dugout Reproduce Overfed De:al Sque3ze

This will return:

  • -V verbose output explaining the entropy of the passphrase.
  • -n 6 Use 6 words in the phrase.
  • --numeric-char-num 2 Include 2 numerical characters in the passphrase.
  • --special-char-num 2 Include 2 special characters in the passphrase..
  • Note the default behaviour to substitute the numeric and special characters randonly into words.

As an aide memoire, you can choose an acrostic for example:

$ xkcd-phrase -a queen
> Quadrant Uncover Enforced Excretion Nacho

A full overview of the available options can be accessed by running following command:

xkcd-phrase --help

Bash-Completion

xkcd-phrase also supports bash-completion. To set this up you need to add the below to your .bashrc file:

eval "$(register-python-argcomplete xkcd-phrase)"

This will then take effect the next time you login. To enable bash-completion immediately, you can run:

source .bashrc

Word Lists

Several word lists are provided with the package. The default, eff-long, was specifically designed by the EFF for passphrase generation and is licensed under CC BY 3.0. As it was originally intended for use with Diceware ensure that the number of words in your passphrase is at least six when using it. Two shorter variants of that list, eff-short and eff-special, are also included. Please refer to the EFF documentation linked above for more information.

Note that xkcd-phrase can be used with any word file of the correct format: a file containing one word per line.

Changelog

  • Version 1.0.0
    • Initial Release

License

This project is released under the GNU GENERAL PUBLIC LICENSE v3. However the original code from redacted/xkcd-password-generator is licensed under the BSD 3-Clause license.

Contributing

Contributions welcome and gratefully appreciated!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xkcd-phrase-1.0.0.tar.gz (76.6 kB view details)

Uploaded Source

Built Distribution

xkcd_phrase-1.0.0-py3-none-any.whl (77.5 kB view details)

Uploaded Python 3

File details

Details for the file xkcd-phrase-1.0.0.tar.gz.

File metadata

  • Download URL: xkcd-phrase-1.0.0.tar.gz
  • Upload date:
  • Size: 76.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for xkcd-phrase-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1cca8bd690781e96d0c1de888fc887ed2f5cf1391a14e31ead304d6a3bb28959
MD5 7d90a4ad0f85ed9f499d4f9cfe5762c7
BLAKE2b-256 843fc1abb22249f43f8763cd921a1ef55934eef500952ee5a059a6d51bb5a0e6

See more details on using hashes here.

File details

Details for the file xkcd_phrase-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: xkcd_phrase-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 77.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for xkcd_phrase-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5c523882db344fbe5e5536d5dea3eeb26b24d762a1c06f0bb6bf1cda47b8629
MD5 64bb939b6383a1e3167b658615ecea37
BLAKE2b-256 b6d4674cbb13912e2916310e0ea3bdb225a7799cd702699b3d28d8b0d15eb093

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page