Skip to main content

A recursive wordlist generator written in python

Project description

Description

A recursive wordlist generator written in Python. For each string position, custom character sets can be defined.

Prerequisites

Python 3.0 or higher

Installation

From PyPI:

pip install wlgen

From GitHub:

git clone https://github.com/tehw0lf/wlgen.git
cd wlgen
pip install .

Usage

Smart Dispatcher (Recommended)

The generate_wordlist() function automatically selects the optimal algorithm based on problem size:

import wlgen

# Auto-select optimal algorithm
charset = {0: '123', 1: 'ABC', 2: 'xyz'}
wordlist = wlgen.generate_wordlist(charset)

# Use the result (list or iterator depending on size)
for word in wordlist if not isinstance(wordlist, list) else wordlist:
    print(word)

Selection Strategy:

  • Tiny (<1K combinations): Uses gen_wordlist (fastest, low memory)
  • Small (1K-100K): Uses gen_wordlist (fast and convenient)
  • Medium+ (100K+): Uses gen_wordlist_iter (optimal throughput, constant memory)

Options:

# Force memory-efficient mode for any size
wordlist = wlgen.generate_wordlist(charset, prefer_memory_efficient=True)

# Manual algorithm selection
wordlist = wlgen.generate_wordlist(charset, method='iter')  # Force iterator
wordlist = wlgen.generate_wordlist(charset, method='list')  # Force list
wordlist = wlgen.generate_wordlist(charset, method='words') # Force gen_words

# Skip input validation for pre-cleaned data (performance optimization)
wordlist = wlgen.generate_wordlist(charset, method='iter', clean_input=True)

Estimate wordlist size before generation:

size = wlgen.estimate_wordlist_size(charset)
print(f"Will generate {size:,} combinations")

Direct Implementation Access

Three implementations are available for direct use:

  • gen_wordlist_iter: Fast generator using itertools.product (~780-810K comb/s).
  • gen_wordlist: Builds entire list in memory. Fastest for small lists (~900K-1.6M comb/s).
  • gen_words: Memory-efficient recursive generator (~210-230K comb/s).

All implementations calculate the n-ary Cartesian product of input character sets.

import wlgen

charset = {0: '123', 1: 'ABC'}

# Use specific implementation
for word in wlgen.gen_wordlist_iter(charset):
    print(word)

Note: NumPy, CUDA, and multiprocessing were investigated but found to provide no performance benefit for this workload. String operations are fundamentally CPU-bound and too fast for parallelization overhead. See issues #17, #18, #20 for detailed analysis.

Development

This project uses uv for dependency management and development workflow.

Setup

Install dependencies:

uv sync --all-extras --group lint

Testing

Run tests:

uv run python -m unittest discover

Benchmarking

Run performance benchmarks:

uv run python wlgen/benchmarks/benchmark.py

Code Quality

Lint code:

uv run ruff check

Auto-fix linting issues:

uv run ruff check --fix

Format code:

uv run ruff format

Building

Build wheel and source distribution:

uv build

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

wlgen-2.0.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wlgen-2.0.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file wlgen-2.0.0.tar.gz.

File metadata

  • Download URL: wlgen-2.0.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for wlgen-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1f029fb9ac10d744fa08e8c832236268d86505398ba5af643b6771740f0714e1
MD5 0a0226b52b39823b75ef3f2129b80ffa
BLAKE2b-256 216f1607cdc94968195b37bff49793f6ba85391f3b7b2e809244ece7dc4d3495

See more details on using hashes here.

File details

Details for the file wlgen-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: wlgen-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for wlgen-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7952fe5a864fe9098f5444d86f926ffe2cd103b6d61559344d61e129cd525694
MD5 5f610d00a021883b2312048fb311f0f6
BLAKE2b-256 343e1ee1ba6d0c681005f8b80bd7f7f00145f05e2afaaf1c6ac788c04564373b

See more details on using hashes here.

Supported by

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