Registry / auth-security / xkcdpass

xkcdpass

JSON →
library1.30.0pypypi✓ verified 85d ago

xkcdpass is a Python library that generates secure multiword passwords or passphrases inspired by the XKCD comic 'Password Strength'. It provides tools to create memorable yet strong passphrases using various wordlists and configuration options. The library is actively maintained with a consistent release cadence, with the current version being 1.30.0.

pip install xkcdpass
INSTALL
IMPORT
SIG · XKCDPASS
X
xkcdpass
auth-securitypythonv1.30.0
Install
1.6s avg
Import
10ms
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.30.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.010s · 26.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.010s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

xkcd_password
import xkcdpass.xkcd_password as xp
import xkcdpass
The primary functions are within the `xkcd_password` submodule, so it's best to import it directly, often aliased as `xp`.

This quickstart demonstrates how to generate a strong, memorable passphrase using the bundled wordlist. It first locates the wordlist, processes it to meet specific length criteria, and then generates a 4-word passphrase using a hyphen as a separator.

import xkcdpass.xkcd_password as xp # Locate the default bundled wordlist wordlist_path = xp.locate_wordlist() # Generate a wordlist from the file # You can also specify language or min/max word length here wordlist = xp.generate_wordlist(wordlist=wordlist_path, min_length=5, max_length=8) # Generate a passphrase with 4 words and a hyphen separator passphrase = xp.generate_xkcdpassword(wordlist, numwords=4, separator='-') print(f"Generated Passphrase: {passphrase}")
xkcdpass --version
Debug
Known issues
breakingThe default separator character for `generate_xkcdpassword` changed from a space (' ') to a hyphen ('-') in version 1.0.0.
fix
If your application relies on the old default, explicitly specify `separator=' '` when calling `generate_xkcdpassword()`.
affects: >=1.0.0
gotchaUsing a small or unsecure wordlist (e.g., custom wordlists with few unique words, or dictionary words easily guessable) significantly compromises the security of generated passphrases.
fix
Always use a robust wordlist, ideally the bundled one via `xp.locate_wordlist()` or a carefully curated, large custom list. Ensure `numwords` is sufficiently high (e.g., 4 or more) to maintain entropy.
affects: all
gotchaThe `generate_wordlist` function returns a `list` of words, not a `set` (which was the case in some older implementations/examples).
fix
If you relied on set-specific operations (like fast `in` checks or automatic deduplication from a list converted to a set), be aware that this behavior changed. For unique words, the generation process already handles this, but type-specific operations might need adjustment.
affects: >=1.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'xkcdpass'
The xkcdpass library is not installed in your current Python environment.
fix
Run `pip install xkcdpass` to install the library.
AttributeError: module 'xkcdpass' has no attribute 'generate_xkcdpassword'
You likely imported `xkcdpass` directly instead of its submodule `xkcd_password`, where the core functions reside.
fix
Change your import statement to `import xkcdpass.xkcd_password as xp` and then call functions like `xp.generate_xkcdpassword()`.
FileNotFoundError: [Errno 2] No such file or directory: '<path_to_your_wordlist>'
The path provided to `generate_wordlist` or `locate_wordlist` does not point to an existing wordlist file.
fix
Ensure the path to your custom wordlist is correct and the file exists. If using the bundled wordlist, ensure `xp.locate_wordlist()` is called correctly and that the library was installed properly to include its data files.
Upgrade
Version history
1.30.0latest on PyPI · released Jan 12, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
28
OpenAI (training)
1
Resources
xkcdpass — pip install xkcdpass · libregistry