{"id":10361,"library":"xkcdpass","title":"XKCD Password Generator","description":"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.","status":"active","version":"1.30.0","language":"en","source_language":"en","source_url":"https://github.com/makeworld-the-better-one/xkcd-password-generator","tags":["password-generation","security","xkcd","passphrase","cryptography"],"install":[{"cmd":"pip install xkcdpass","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary functions are within the `xkcd_password` submodule, so it's best to import it directly, often aliased as `xp`.","wrong":"import xkcdpass","symbol":"xkcd_password","correct":"import xkcdpass.xkcd_password as xp"}],"quickstart":{"code":"import xkcdpass.xkcd_password as xp\n\n# Locate the default bundled wordlist\nwordlist_path = xp.locate_wordlist()\n\n# Generate a wordlist from the file\n# You can also specify language or min/max word length here\nwordlist = xp.generate_wordlist(wordlist=wordlist_path, min_length=5, max_length=8)\n\n# Generate a passphrase with 4 words and a hyphen separator\npassphrase = xp.generate_xkcdpassword(wordlist, numwords=4, separator='-')\nprint(f\"Generated Passphrase: {passphrase}\")","lang":"python","description":"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."},"warnings":[{"fix":"If your application relies on the old default, explicitly specify `separator=' '` when calling `generate_xkcdpassword()`.","message":"The default separator character for `generate_xkcdpassword` changed from a space (' ') to a hyphen ('-') in version 1.0.0.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"Using 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.","severity":"gotcha","affected_versions":"all"},{"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.","message":"The `generate_wordlist` function returns a `list` of words, not a `set` (which was the case in some older implementations/examples).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install xkcdpass` to install the library.","cause":"The xkcdpass library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'xkcdpass'"},{"fix":"Change your import statement to `import xkcdpass.xkcd_password as xp` and then call functions like `xp.generate_xkcdpassword()`.","cause":"You likely imported `xkcdpass` directly instead of its submodule `xkcd_password`, where the core functions reside.","error":"AttributeError: module 'xkcdpass' has no attribute 'generate_xkcdpassword'"},{"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.","cause":"The path provided to `generate_wordlist` or `locate_wordlist` does not point to an existing wordlist file.","error":"FileNotFoundError: [Errno 2] No such file or directory: '<path_to_your_wordlist>'"}]}