A lightning-fast, privacy-first Streamlit app for generating military-grade passwords.
Random Β· Memorable Β· PIN β all generated locally with zero storage, zero tracking.
| Feature | Description |
|---|---|
| π² Random Password | Cryptographically secure via Python's secrets module β uppercase, lowercase, digits, symbols |
| π§ Memorable Password | XKCD-style word phrases using the full NLTK English corpus |
| π’ PIN Code | Secure numeric codes with optional sequential-pattern avoidance |
| π Strength Evaluation | Real-time score (0β100) with entropy bits, charset size, and crack-time estimate |
| πΎ Export | Download as plain .txt or structured .json with full metadata |
| π Session History | Auto-tracks the last 30 passwords; cleared on refresh |
| π Inline Guides | Every section has a collapsible explanation β no documentation needed |
| π Dark UI | Modern dark interface with gradient accents |
| π 100% Private | All generation happens in Python β nothing ever leaves your machine |
- Python 3.9+ (3.12 recommended)
pippackage manager
# 1. Clone the repository
git clone https://github.com/Baset98/password-generator.git
cd password-generator/src
# 2. (Recommended) Create a virtual environment
python -m venv .venv
source .venv/bin/activate # Linux / macOS
.venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Download the NLTK word corpus (one-time setup)
python -c "import nltk; nltk.download('words')"
# 5. Launch the app
streamlit run dashboard.py
or
reamlit run src/dashboard.pyThe app opens automatically at http://localhost:8501.
src/
βββ dashboard.py # Main Streamlit application
βββ password_generators.py # Password generation classes (OOP, fully typed)
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ images/
---
## π§ Core Components
### `password_generators.py` β Class Architecture
PasswordGenerator (Abstract Base Class) β βββ compute_strength(password) β (score: int, label: str) βββ charset_size(password) β int βββ entropy_bits(password) β int βββ crack_time_label(password) β str β βββ RandomPasswordGenerator β length, include_uppercase/lowercase/digits/symbols β exclude_similar, no_repeated_characters, use_secrets β βββ MemorablePasswordGenerator β no_of_words, separator, capitalization β vocabulary (NLTK), suffix_length β βββ PinCodeGenerator length, avoid_sequential
| Class | Key Method | Randomness Source |
|-------|-----------|-------------------|
| `RandomPasswordGenerator` | `generate() β str` | `secrets.choice()` |
| `MemorablePasswordGenerator` | `generate() β str` | `secrets.SystemRandom().sample()` |
| `PinCodeGenerator` | `generate() β str` | `secrets.randbelow(10)` |
### `dashboard.py` β Section Map
| Section | Content |
|---------|---------|
| β Select Type | Radio tabs + inline guide |
| β‘ Configure | Type-specific sliders, checkboxes, toggles + guide |
| β’ Generate | Primary action button |
| β£ Display | Password code block Β· strength bar Β· 4 metric cards |
| β€ Download | TXT and JSON export buttons + format guide |
| β₯ History | Last 30 passwords with strength badges |
| Guide | Full security reference (always accessible) |
---
## π‘οΈ Security & Privacy
### Strength Scoring Algorithm
score = length_score + diversity_score + complexity_bonus
length_score = min( max(length - 4, 0) / 24 Γ 40, 40 ) # 0β40 pts diversity_score = (char_classes_used / 4) Γ 40 # 0β40 pts complexity_bonus = 20 if digits AND symbols # 0β20 pts 10 if digits OR symbols 0 otherwise
Thresholds: 0β39 Weak Β· 40β59 Medium Β· 60β79 Strong Β· 80β100 Very Strong
### Entropy Formula
H = length Γ logβ(charset_size) (bits)
Examples: 16 chars, all types (charset=94) β 16 Γ 6.55 β 105 bits β 12 chars, lower+digit(charset=36) β 12 Γ 5.17 β 62 bits 4 words, ~170k vocab β 4 Γ 17.4 β 70 bits β
### Privacy Guarantee
Your Machine β βΌ βββββββββββββββββββββββββββββββββββββββββββββ β Python Runtime (Streamlit) β β β β secrets.choice() β β βββ OS entropy pool β β βββ /dev/urandom (Linux/macOS) β β βββ CryptGenRandom (Windows) β β β β β No network calls β β β No database writes β β β No cookies / analytics β β β Session memory only β βββββββββββββββββββββββββββββββββββββββββββββ
---
## π¦ Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| [`streamlit`](https://streamlit.io/) | 1.45.x | Interactive web UI framework |
| [`nltk`](https://www.nltk.org/) | 3.9.x | English word corpus for memorable passwords |
**Standard library used:** `abc`, `json`, `math`, `random`, `secrets`, `string`, `datetime`
---
## π How to Use
1. **Select Type** β Choose Random, Memorable, or PIN from the radio buttons.
2. **Configure** β Adjust length, character types, separators, or other options.
3. **Generate** β Click *β‘ Generate New Password*. The password appears instantly with its strength analysis.
4. **Evaluate** β Read the strength score, entropy in bits, charset size, and estimated crack time.
5. **Download** β Save as `.txt` (password only) or `.json` (with full metadata).
6. **Explore Guides** β Every section has a collapsible guide. Expand them to learn more.
---
## π€ Contributing
Contributions are welcome!
```bash
# Fork on GitHub, then:
git clone https://github.com/YOUR_USERNAME/password-generator.git
cd password-generator
git checkout -b feature/your-feature-name
# ... make your changes ...
git commit -m "feat: describe your change"
git push origin feature/your-feature-name
# Open a Pull Request
Guidelines:
- Follow PEP 8 style.
- Add type hints to all new functions.
- Add docstrings to all new classes and methods.
- Test your changes locally before submitting.
Ideas welcome:
- π Additional language word lists (Arabic, Persian, Frenchβ¦)
- π Passphrase strength presets (NIST levels)
- π Strength history chart
- π Deploy to Streamlit Cloud
MIT License Β© 2025 Baset98
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, subject to the above copyright notice
appearing in all copies.
Built with β€οΈ using Python & Streamlit
β Star this repo Β· π Report a bug Β· π‘ Request a feature