RPG - Rust Password Generator
: .:
.% -#
..:... =%*+*- .*#*#*:: . . -++.
-==+++*****###***+=++==++*%@@@@#+++++++++##%%%%***++++++++++=++====+=++++++%@.
:-=++*##%%@@@@@%%##**+==+++==+==#%@%%%%#+**++**#######*****+========+==+*%%@#
.:::::. -::%###: .*#- .::
..*###. :#%-
.#%* .=+.
:#%#
:::
A fast, secure, and customizable command-line password generator written in Rust.
Features
- ASCII art banner: Displays a stylized RPG launcher banner on execution
- Customizable character sets: Control which types of characters to include (lowercase, uppercase, numerals, symbols)
- Character exclusion: Exclude specific characters or ranges from generated passwords
- Character inclusion: Restrict passwords to only specific character sets
- Pattern-based generation: Generate passwords from patterns (e.g.,
LLLNNNSSSfor 3 lowercase, 3 numeric, 3 symbols) - Minimum requirements: Enforce minimum counts of capitals, numerals, or symbols
- Reproducible passwords: Use seeds to generate the same passwords repeatedly
- Multiple output formats: Text (default) or JSON with entropy information
- Clipboard integration: Copy passwords directly to clipboard
- Table output: Display multiple passwords in a formatted table
- Quiet mode: Suppress banner and headers for script-friendly output
- Uniform distribution: Passwords are generated with uniform character distribution
- Fast and efficient: Pre-allocated memory and optimized character set building
- Well-tested: Comprehensive unit tests (17+) and integration tests
Installation
From Crates.io
From Source
The binary will be available at target/release/rpg.
Usage
Basic Usage
Generate 5 passwords with default settings (16 characters, all character types):
Options
-l, --length <LENGTH>: Set password length (default: 16, max: 10,000)-c, --capitals-off: Disable capital letters-n, --numerals-off: Disable numerals-s, --symbols-off: Disable symbols-e, --exclude-chars <CHARS>: Exclude specific characters or ranges (e.g.,a-z,0-9)--include-chars <CHARS>: Include only specific characters or ranges (overrides type flags)--min-capitals <N>: Minimum number of capital letters required--min-numerals <N>: Minimum number of numerals required--min-symbols <N>: Minimum number of symbols required-t, --table: Display passwords in table format-q, --quiet: Suppress banner and header output--seed <SEED>: Seed for reproducible password generation--format <FORMAT>: Output format: "text" (default) or "json"--copy: Copy first password to clipboard--pattern <PATTERN>: Generate passwords from a pattern (L=lowercase, U=uppercase, N=numeric, S=symbol)
Examples
Generate 10 passwords of length 20:
Generate 5 passwords without capital letters:
Generate 5 passwords with only alphabetic characters:
Generate 5 passwords excluding specific characters or ranges:
Display passwords in table format:
Generate passwords with custom length and character restrictions:
Generate passwords with minimum requirements:
Generate reproducible passwords with seed:
Output in JSON format:
Copy first password to clipboard:
Use only specific characters:
Generate passwords from a pattern:
Character Sets
The generator uses the following character ranges:
- Lowercase letters:
a-z(always included) - Uppercase letters:
A-Z(can be disabled with--capitals-off) - Numerals:
0-9(can be disabled with--numerals-off) - Symbols: All ASCII printable symbols (can be disabled with
--symbols-off)!"#$%&'()*+,-./(33-47):;<=>?@(58-64)- `[]^_`` (91-96)
{|}~(123-126)
Error Handling
The generator validates inputs and provides clear error messages:
- Invalid password length or count
- All character types disabled
- All characters excluded
Performance
- Pre-allocated memory for efficient generation
- O(1) character exclusion checking using HashSet
- Single character set build for all passwords
- Optimized random sampling
- Benchmarked with criterion for performance tracking
Library Usage
RPG can also be used as a library in your Rust projects:
[]
= "1.1.0"
use ;
use Rng;
let args = PasswordArgs ;
let char_set = build_char_set?;
let mut rng = rng;
let gen_params = GenerationParams ;
let passwords = generate_passwords;
// Or use pattern-based generation
let pattern = parse_pattern?;
let gen_params = GenerationParams ;
let passwords = generate_passwords;
Testing
Run the test suite:
# Run all tests
# Run only unit tests
# Run only integration tests
# Run with output
Benchmarks
Run performance benchmarks:
This will generate HTML reports in target/criterion/.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
- Clone the repository
- Run tests:
cargo test - Run clippy:
cargo clippy - Format code:
cargo fmt
Pre-commit Hooks
Optional pre-commit hooks are available to ensure code quality. See PRE_COMMIT_HOOKS.md for detailed documentation.
Quick setup:
This will run formatting, linting, and tests before each commit.