A simple and secure command-line password generator written in Rust.
- 🎲 Generate random passwords of any length
- 🔤 Support for uppercase and lowercase letters
- 🔢 Include numbers
- 💥 Optional use of special characters
- ✅ Built-in password strength checking
- 🚀 High performance thanks to Rust
- 📦 Single executable with no dependencies
- Rust 1.70 or higher (for building from source only)
- Or simply download the ready-made executable
Download the executable for your OS from the Releases section
git clone https://github.com/Pavstyuk/password-generator.git
cd password_generator
cargo build --releaseThe executable will appear in target/release/password_generator (or .exe on Windows)
# Generate a 12-character password (default)
./password_generator
# Specify the password length
./password_generator --length 20
# Use special characters
./password_generator --special
# Parameter combination
./password_generator -l 16 -s| Parameter | Short Form | Description | Default Value |
|---|---|---|---|
--length |
-l |
Password length | 12 |
--special |
-s |
Enable special characters | false |
--help |
-h |
Show help | - |
# Short password without special characters
./password_generator -l 8
# Sample output: kT9mN2pQ
# Long password with special characters
./password_generator -l 32 -s
# Sample output: gH7#mK2@qL9!nP4$rT5&yU8*vB3?xC6
# Get help
./password_generator --helpclap(4.4) — parsing command line argumentsrand(0.8) — generating random numbers
# Without arguments
cargo run
# With arguments
cargo run -- -l 16 -s
# Release build
cargo build --release./password_generator -l 20 -s > my_password.txtfor i in {1..5}; do
echo "Password $i: $(./password_generator -l 15 -s)"
done#!/bin/bash
PASSWORD=$(./password_generator -l 24 -s)
echo "Your new password: $PASSWORD"- ✅ A cryptographically strong random number generator is used (
rand::thread_rng) - ✅ Forced checking for all character types
- ✅ The password is not saved in logs or command history
- ✅ The program does not store or transmit generated passwords
- For regular websites, use passwords 12-16 characters long
- For important accounts (email, banks), use 20+ characters
- Always include special characters for maximum security
- Don't use the same password for multiple services
Solution: Add execute permissions to
chmod +x password_generatorSolution: The program will return an error because the password must be at least 4 characters
./password_generator -l 3
# Error: Password length must be at least 4 characters| Password Length | Generation Time (debug) | Generation Time (release) |
|---|---|---|
| 12 characters | ~50µs | ~5µs |
| 100 characters | ~200µs | ~20µs |
| 1000 characters | ~1.5ms | ~150µs |
MIT License. Feel free to use, modify, and redistribute.