Package: xkcdpass
xkcdpassA flexible and scriptable password generator which generates strong passphrases, inspired byXKCD 936:$ xkcdpass
> correct horse battery stapleInstallxkcdpasscan be easily installed using pip:pip install xkcdpassor manually:python setup.py installSourceThe latest development version can be found on github:https://github.com/redacted/XKCD-password-generatorContributions welcome and gratefully appreciated!RequirementsPython 2 (version 2.7 or later), or Python 3 (version 3.4 or later). Running module unit tests on Python 2 requiresmockto be installed.Runningxkcdpassxkcdpasscan be called with no arguments:$ xkcdpass
> pinball previous deprive militancy bereaved numericwhich returns a single password, using the default dictionary and default settings. Or you can mix whatever arguments you want:$ xkcdpass --count=5 --acrostic='chaos' --delimiter='|' --min=5 --max=6 --valid-chars='[a-z]'
> collar|highly|asset|ovoid|sultan
> caper|hangup|addle|oboist|scroll
> couple|honcho|abbot|obtain|simple
> cutler|hotly|aortae|outset|stool
> cradle|helot|axial|ordure|shalewhich returns--count=55 passwords to choose from--acrostic='chaos'the first letters of which spell ‘chaos’--delimiter='|'joined using ‘|’--min=5--max=6with words between 5 and 6 characters long--valid-chars='[a-z]'using only lower-case letters (via regex).A concise overview of the availablexkcdpassoptions can be accessed via:xkcdpass --help

Usage: xkcdpass [options]

Options:
    -h, --help
                                show this help message and exit
    -w WORDFILE, --wordfile=WORDFILE
                                Specify that the file WORDFILE contains the list of
                                valid words from which to generate passphrases. Multiple
                                wordfiles can be provided, separated by commas.
                                Provided wordfiles: eff-long (default), eff-short,
                                eff-special, legacy, spa-mich (Spanish), fin-kotus (Finnish)
                                ita-wiki (Italian), ger-anlx (German), nor-nb (Norwegian),
                                fr-freelang (French), pt-ipublicis / pt-l33t-ipublicis (Portuguese)
                                swe-short (Swedish)
    --min=MIN_LENGTH
                                Minimum length of words to make password
    --max=MAX_LENGTH
                                Maximum length of words to make password
    -n NUMWORDS, --numwords=NUMWORDS
                                Number of words to make password
    -i, --interactive
                                Interactively select a password
    -v VALID_CHARS, --valid-chars=VALID_CHARS
                                Valid chars, using regexp style (e.g. '[a-z]')
    -V, --verbose
                                Report various metrics for given options, including word list entropy
    -a ACROSTIC, --acrostic=ACROSTIC
                                Acrostic to constrain word choices
    -c COUNT, --count=COUNT
                                number of passwords to generate
    -d DELIM, --delimiter=DELIM
                                separator character between words
    -R, --random-delimiters
                                use randomised delimiters
    -D DELIMITERS, --valid-delimiters=DELIMETERS
                                delimeters to choose from, used with -
    -s SEP, --separator SEP
                                Separate generated passphrases with SEP.
    -C CASE, --case CASE
                                Choose the method for setting the case of each word in
                                the passphrase. Choices: ['alternating', 'upper',
                                'lower', 'random', 'capitalize', 'as-is'] (default: 'lower').
    --allow-weak-rng
                                 Allow fallback to weak RNG if the system does not
                                support cryptographically secure RNG. Only use this if
                                you know what you are doing.Word listsSeveral word lists are provided with the package. The default,eff-long, was specifically designed by the EFF forpassphrase generationand is licensed underCC 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-shortandeff-special, are also included. Please refer to the EFF documentation linked above for more information.The original word list fromxkcdpassversions earlier than 1.10.0 is also provided as a convenience, and is available underlegacy. This word list is derived mechanically from12Dictsby Alan Beale. It is the understanding of the author ofxkcdpassthat purely mechanical transformation does not imbue copyright in the resulting work. The documentation for the 12Dicts project athttp://wordlist.aspell.net/12dicts/contains the following dedication:The 12dicts lists were compiled by Alan Beale. I explicitly release them to the public domain, but request acknowledgment of their use.Note that the generator can be used with any word file of the correct format: a file containing one ‘word’ per line.Additional languagesSpanish: a modifed version of archive.umich.edu in the/linguisticsdirectory. It includes ~80k words. Less than 5 char. and latin-like words were deleted using regex. This list is public domain, seehere.Finnish: a modified version of the Institute for the Languages of FinlandXML word list. Profanities and expressions containing spaces were removed using regex. The resulting list contains ~93k words. The list is published under GNU LGPL, EUPL 1.1 and CC-BY 3.0 licenses.Italian: generated from dumps of the Italian-language Wikipedia, which is released under the Creative Commons Attribution-Share-Alike 3.0 licence.German (ger-anlx): based onthis GPL v3 list. Single and double character words have been removed.German (eff_large_de_sample.wordlist): based onthis public domain dictionary. Converted to UTF-8 and randomly sampled to reduce file size.Norwegian: a modified version ofNorsk Ordbank in Norwegian Bokmål 2005, 2018-06-28 update, which is released under theCC-BY 4.0 license. Regex has been used to alter the list for cleanup and removal of words with impractical characters. The resulting list contains ~137k words.French: One cleaned version ofthis list(public domain), and one filtered to remove potentially offensive words.Portuguese: Converted variant of the LibreOffice / Firefox Portuguese dictionary (fromthis link. GPL and BSD licenced.Swedish: a modified version ofMartin Lindhe’s Swedish word list(MIT license). Modifications also released under MIT license.Additional language word lists are always welcome!Using xkcdpass as an imported moduleThe built-in functionality ofxkcdpasscan be extended by importing the module into python scripts. An example of this usage is provided inexample_import.py, which randomly capitalises the letters in a generated password.example_json.pydemonstrates integration of xkcdpass into a Django project, generating password suggestions as JSON to be consumed by a Javascript front-end.A simple use of import:from xkcdpass import xkcd_password as xp

# create a wordlist from the default wordfile
# use words between 5 and 8 letters long
wordfile = xp.locate_wordfile()
mywords = xp.generate_wordlist(wordfile=wordfile, min_length=5, max_length=8)

# create a password with the acrostic "face"
print(xp.generate_xkcdpassword(mywords, acrostic="face"))When used as an imported module,generate_wordlist()takes the following args (defaults shown):wordfile=None,
min_length=5,
max_length=9,
valid_chars='.'Whilegenerate_xkcdpassword()takes:wordlist,
numwords=6,
interactive=False,
acrostic=False,
delimiter=" "Insecure random number generatorsxkcdpassuses crytographically strong random number generators where possible (provided byrandom.SystemRandom()on most modern operating systems). From version 1.7.0 falling back to an insecure RNG must be explicitly enabled, either by using a new command line variable before running the script:xkcdpass --allow-weak-rngor setting the appropriate environment variable:export XKCDPASS_ALLOW_WEAKRNG=1Changelog1.19.8Enablespython -m xkcdpassusage1.19.7Adds Swedish wordlist, improvements to test suite, improvements to setup.py (excludes examples from install)1.19.6Fixes randomly failing unit test1.19.5Adds “as-is” option for case1.19.4Makes randomised delimiters behavior consistent with fixed delimeters1.19.3Restore a randomly sampled version of eff_large_de wordlist1.19.2Reduction in install size1.19.1Improvements to help text, handle rare case where arguments lead to empty wordlist1.19.0Initial support for multiple wordfiles1.18.2fixes for README1.18.0Added randomised delimiters1.17.6Bugfixes1.17.5Bugfixes1.17.4Improvements to French dictionary1.17.3Updated license and supported versions1.17.2Compatibility fix for 2.x/3.x1.17.1Fix issue with README and unicode encoding1.17.0Add French, Norwegian, and Portuguese dictionaries. Bugfixes and improvements to tests (WIP).1.16.5Adds title case option for–caseLicenseThis is free software: you may copy, modify, and/or distribute this work under the terms of the BSD 3-Clause license.
See the fileLICENSE.BSDfor details.