Skip to content

πŸ” Cryptographically secure password generator with entropy analysis, passphrase support, and Typer CLI

License

Notifications You must be signed in to change notification settings

hatimhtm/Fortress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏰 Fortress

CI Python 3.9+ License: MIT

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.

Fortress Demo

✨ Features

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

πŸš€ Installation

# Install core library only
pip install fortress

# Install with CLI support (recommended)
pip install "fortress[cli]"

# Install for development
pip install -e ".[dev]"

πŸ“– Usage

Command Line

# 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 -q

Python Library

from 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")

πŸ“ Project Structure

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

πŸ—οΈ Architecture

  • 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

πŸ”’ Security

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 secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.

πŸ§ͺ Development

# 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

πŸ“Š Password Strength Guide

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

πŸ“„ License

MIT


πŸ‘€ Author

Hatim El Hassak β€” Full-Stack Engineer

Portfolio LinkedIn Email

About

πŸ” Cryptographically secure password generator with entropy analysis, passphrase support, and Typer CLI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages