Secure password generator CLI written in Python. Generate strong, random passwords from the command line with customizable character sets.
- Default behavior: All character types enabled by default (lowercase, uppercase, digits, symbols)
- Specify password length (
-l) and quantity (-n) - Include/exclude character types:
--lower- Lowercase letters--upper- Uppercase letters--digits- Digits--symbols- Symbols
--no-ambiguous- Exclude confusing characters (l, 1, I, O, 0)--symbol-set- Custom symbol set--no-ensure- Disable "at least one from each type" rule--entropy- Calculate and display password entropy--clipboard/-c- Copy password to clipboard--format- Output format:plain,json,delimited--save-config- Save current options as defaults--config- Show current configuration- Shell completions for bash, zsh, and fish
pipx install git+https://github.com/kilyabin/GenPassClone the repo and run the install script:
git clone https://github.com/kilyabin/GenPass.git
cd GenPass
./install.shpipx install --editable .
# or
pip install -e .Generate a single password (default 16 characters, all character types):
genpassGenerate a password with specific character types:
genpass --lower --upper --digits --symbolsGenerate 5 passwords of length 20:
genpass -l 20 -n 5Generate a 32-character password:
genpass -l 32Password without symbols (only letters and digits):
genpass --lower --upper --digitsOnly lowercase and digits:
genpass --lower --digitsUse a custom symbol set:
genpass --symbols --symbol-set "!@#%&"Exclude confusing characters like l, 1, I, O, 0:
genpass --no-ambiguousCombine with other options:
genpass -l 20 --no-ambiguous --lower --upper --digitsPlain text (default):
genpass -n 3JSON format:
genpass -n 3 --format jsonOutput:
{
"passwords": [
"abc123...",
"def456...",
"ghi789..."
]
}Delimited format (one per line):
genpass -n 3 --format delimitedDisplay password entropy (in bits):
genpass --entropyOutput:
Kx9#mP2$vL5@nQ8w
# Entropy: 94.56 bits
Copy the generated password to clipboard:
genpass --clipboard
# or
genpass -cOutput:
✓ Copied to clipboard
Kx9#mP2$vL5@nQ8w
Note: Clipboard support requires
pyperclip. Install withpip install pyperclip.
Save default settings:
genpass -l 24 --no-ambiguous --save-configShow current configuration:
genpass --configConfiguration is stored in ~/.genpass/config.json.
Generate a password for a website:
genpass -l 16 --clipboardGenerate multiple passwords and save to file:
genpass -n 10 -l 20 --format json > passwords.jsonGenerate a memorable password (no ambiguous chars):
genpass -l 12 --no-ambiguousGenerate a high-entropy password:
genpass -l 32 --entropyScript-friendly JSON output:
genpass --format json | jq -r '.passwords[0]'Set default password length for all future sessions:
genpass -l 20 --save-config
genpass # Now generates 20-char passwords by defaultAfter installation, completions are automatically copied to your shell folders. Restart your shell or source the completion files manually:
Bash
source ~/.local/share/bash-completion/completions/genpassZsh
source ~/.local/share/zsh/site-functions/_genpassFish
source ~/.local/share/fish/vendor_completions.d/genpass.fish- Install in editable mode:
pipx install --editable .
# or
pip install -e .- Install dev dependencies:
pip install -e ".[dev]"- Run linting:
ruff check genpass/
mypy genpass/
black --check genpass/- Run tests:
pytestUse GenPass as a Python library:
from genpass import generate_password, get_character_pools, calculate_entropy
# Get character pools
pools = get_character_pools(
use_lower=True,
use_upper=True,
use_digits=True,
use_symbols=True,
symbol_set="!@#$%",
exclude_ambiguous=False,
)
# Generate password
password = generate_password(length=16, pools=pools)
print(password)
# Calculate entropy
entropy = calculate_entropy(password, sum(len(p) for p in pools))
print(f"Entropy: {entropy:.2f} bits")positional arguments:
(none)
options:
-h, --help Show help message
-l, --length LENGTH Password length (default: 16)
-n, --count COUNT Number of passwords (default: 1)
--lower Include lowercase letters
--upper Include uppercase letters
--digits Include digits
--symbols Include symbols
--symbol-set SET Custom symbol set
--no-ensure Disable ensure-each-type rule
--no-ambiguous Exclude ambiguous characters
--entropy Show password entropy
-c, --clipboard Copy to clipboard
--format FORMAT Output format: plain, json, delimited
--config Show current configuration
--save-config Save options as defaults
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (
pytest,ruff check,mypy) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project uses:
- Black for code formatting
- Ruff for linting
- MyPy for type checking
Install dev dependencies and set up pre-commit hooks:
pip install -e ".[dev]"
pre-commit installThis project is licensed under the MIT License – see the LICENSE file for details.
See CHANGELOG.md for version history.