A command-line password generator tool built in Rust that provides flexible options for generating secure passwords and memorable passphrases.
- ๐ Random passwords - Cryptographically secure alphanumeric passwords
- ๐ Memorable passwords - Word-based passwords like "Correct-Horse-Battery-42"
- ๐๏ธ Configurable - Customize length, character sets, and more
- โก Fast - Instant generation with minimal overhead
- ๐ก๏ธ Secure - Uses cryptographically secure random number generation
git clone https://github.com/minhchu/pwgen.git
cd pwgen
cargo install --path .This will compile and install the pwgen binary to ~/.cargo/bin/ (make sure it's in your PATH).
# Generate a default password (16 chars, alphanumeric)
pwgen
# Output: Kj8mNp2xQr5tYw9v
# Generate a 24-character password
pwgen -l 24
# Output: Kj8mNp2xQr5tYw9vAb3cDe7f
# Generate a password with special characters
pwgen -s
# Output: Kj8@mNp2#xQr5$tY
# Generate a memorable password
pwgen --memorable
# Output: Correct-Horse-Battery-42
# Generate a password without numbers
pwgen --no-numbers
# Output: KjXmNpVxQrUtYwZv
# Generate 5 passwords
pwgen -c 5
# Output:
# Kj8mNp2xQr5tYw9v
# Xp4hLm7bRt2wYq6n
# Zf9kBc3jVs8dNg1m
# Ht5pWr8yNk2vJf4x
# Lq7sYd6gMb3cRe9z
# Generate 3 memorable passwords with special characters
pwgen -m -s -c 3| Option | Short | Long | Description | Default |
|---|---|---|---|---|
| Length | -l |
--length |
Password length | 16 |
| Special Characters | -s |
--special |
Include special characters (!@#$%^&*) | false |
| No Numbers | --no-numbers |
Exclude numbers (0-9) | false | |
| Memorable | -m |
--memorable |
Generate memorable password (word-based) | false |
| Count | -c |
--count |
Number of passwords to generate | 1 |
| Help | -h |
--help |
Show help message | - |
| Version | -V |
--version |
Show version | - |
You can also use pwgen as a library in your Rust projects:
use pwgen::{PasswordConfig, generate_passwords};
fn main() {
// Generate a default password
let config = PasswordConfig::default();
let passwords = generate_passwords(&config);
println!("{}", passwords[0]);
// Generate a memorable password with special characters
let config = PasswordConfig {
memorable: true,
include_special: true,
count: 3,
..Default::default()
};
let passwords = generate_passwords(&config);
for password in passwords {
println!("{}", password);
}
}- Uses
randcrate withOsRngfor cryptographically secure random number generation - Ensures character diversity in random passwords (at least one lowercase, uppercase, and number/special if enabled)
- Shuffles password characters to avoid predictable patterns
MIT License - see LICENSE for details.