Skip to content

minhchu/pwgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

pwgen - Password Generator CLI

A command-line password generator tool built in Rust that provides flexible options for generating secure passwords and memorable passphrases.

Features

  • ๐Ÿ” 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

Installation

From source

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).

Usage

# 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

CLI Options

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 -

Library Usage

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);
    }
}

Security

  • Uses rand crate with OsRng for 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

License

MIT License - see LICENSE for details.

About

๐Ÿ” A fast, flexible command-line password generator built in Rust. Generate secure random passwords or memorable word-based passphrases with customizable length, special characters, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages