A cryptographically secure password generator with entropy estimation.
Fortress uses Python's secrets module to generate passwords that are suitable for security-sensitive applications. It includes entropy calculation, strength estimation, and a beautiful CLI.
| Feature | Description |
|---|---|
| π Cryptographically Secure | Uses secrets module, not random |
| π Entropy Calculation | Know exactly how strong your password is |
| β±οΈ Crack Time Estimation | See how long it would take to crack |
| π¨ Beautiful CLI | Rich terminal output with colors and progress |
| π¦ Zero Dependencies | Core library has no dependencies |
| π§ Configurable | Customize character sets, length, and more |
| π§ͺ Well Tested | 80%+ test coverage with pytest |
# Install core library only
pip install fortress
# Install with CLI support (recommended)
pip install "fortress[cli]"
# Install for development
pip install -e ".[dev]"# Generate a 16-character password (default)
fortress generate
# Generate a 32-character password
fortress generate -l 32
# Generate without symbols (for sites that don't allow them)
fortress generate --no-symbols
# Generate multiple passwords
fortress generate -c 5
# Generate a memorable passphrase
fortress passphrase
# Check strength of an existing password
fortress check "MyP@ssw0rd123"
# Quiet mode (just the password, for scripting)
fortress generate -qfrom fortress import generate_password, PasswordConfig, calculate_entropy
# Generate with defaults (16 chars, all character types)
password = generate_password()
# Generate with custom length
password = generate_password(length=32)
# Generate with custom configuration
config = PasswordConfig(
length=24,
use_symbols=False,
exclude_ambiguous=True, # No 0/O, 1/l/I confusion
)
password = generate_password(config=config)
# Check entropy
entropy = calculate_entropy(password)
print(f"Entropy: {entropy:.1f} bits")fortress/
βββ __init__.py # Public API
βββ core/
β βββ generator.py # Password generation logic
β βββ entropy.py # Strength calculation
βββ cli/
β βββ __init__.py # Typer CLI application
βββ utils/
βββ display.py # Terminal display utilities
- Core Module: Pure Python, no dependencies, cryptographically secure
- CLI Module: Optional, uses Typer and Rich for beautiful output
- Utils Module: Display helpers with graceful fallback
Fortress uses secrets.choice() instead of random.choice(). The secrets module is specifically designed for generating cryptographically strong random numbers suitable for managing secrets such as passwords.
From the Python docs:
The
secretsmodule is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.
# Clone and install
git clone https://github.com/hatimhtm/Fortress.git
cd Fortress
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=fortress --cov-report=html
# Lint
ruff check .
# Type check
mypy fortress| Entropy (bits) | Strength | Crack Time* |
|---|---|---|
| < 28 | Very Weak | Instantly |
| 28-35 | Weak | Minutes |
| 36-59 | Fair | Hours to days |
| 60-127 | Strong | Years |
| β₯ 128 | Very Strong | Centuries |
*Assuming 10 billion attempts/second
Hatim El Hassak β Full-Stack Engineer
