Skip to content

Pavstyuk/password-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Password Generator

A simple and secure command-line password generator written in Rust.

✨ Features

  • 🎲 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

📋 Requirements

  • Rust 1.70 or higher (for building from source only)
  • Or simply download the ready-made executable

🚀 Installation

Method 1: Ready-to-use binary

Download the executable for your OS from the Releases section

Method 2: Building from source

git clone https://github.com/Pavstyuk/password-generator.git
cd password_generator
cargo build --release

The executable will appear in target/release/password_generator (or .exe on Windows)

💻 Usage

Basic Usage

# 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

Command Line Parameters

Parameter Short Form Description Default Value
--length -l Password length 12
--special -s Enable special characters false
--help -h Show help -

Examples

# 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 --help

Dependencies

  • clap (4.4) — parsing command line arguments
  • rand (0.8) — generating random numbers

Run in development mode

# Without arguments
cargo run

# With arguments
cargo run -- -l 16 -s

# Release build
cargo build --release

🎯 Examples of use in scripts

Saving a password to a file

./password_generator -l 20 -s > my_password.txt

Generating multiple passwords

for i in {1..5}; do
echo "Password $i: $(./password_generator -l 15 -s)"
done

Usage in a bash script

#!/bin/bash
PASSWORD=$(./password_generator -l 24 -s)
echo "Your new password: $PASSWORD"

🛡️ Security

  • ✅ 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

Usage Recommendations

  • 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

🐛 Known Issues and Solutions

Issue: "Permission denied" when running on Linux/Mac

Solution: Add execute permissions to

chmod +x password_generator

Issue: Error if password length is less than 4 characters

Solution: 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

📊 Performance

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

📝 License

MIT License. Feel free to use, modify, and redistribute.

About

A simple and secure command-line password generator written in Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages