Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

PassGen Banner

πŸ” PassGen β€” Password Generator

Python Streamlit NLTK License: MIT Code Style: PEP8

A lightning-fast, privacy-first Streamlit app for generating military-grade passwords.
Random Β· Memorable Β· PIN β€” all generated locally with zero storage, zero tracking.

PassGen Dashboard Screenshot

✨ Key Features

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

πŸš€ Quick Start

Prerequisites

  • Python 3.9+ (3.12 recommended)
  • pip package manager

Installation

# 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.py

The app opens automatically at http://localhost:8501.


πŸ“ Project Structure

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

πŸ“„ License

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

About

πŸ” Secure password generator built with Python & Streamlit β€” Random,

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages