Skip to content

๐Ÿ” A secure command-line password generator with QR code generation and clipboard integration, powered by /dev/urandom

License

Notifications You must be signed in to change notification settings

0xEtherPunk/passGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

aa04c4e ยท Nov 25, 2024

History

11 Commits
Nov 20, 2024
Nov 25, 2024
Nov 25, 2024
Nov 20, 2024
Nov 25, 2024
Nov 25, 2024
Nov 23, 2024
Nov 25, 2024
Nov 25, 2024
Nov 22, 2024
Nov 22, 2024

Repository files navigation

๐Ÿ” PassGen

Secure Password Generator & Encryption Tool

Go Version License

Demo

๐Ÿš€ Features

  • ๐ŸŽฒ Cryptographically secure password generation
  • ๐Ÿ”’ XChaCha20-Poly1305 encryption
  • ๐ŸŒ Multi-language BIP39 mnemonic support
  • ๐Ÿ“ฑ QR code generation and reading
  • ๐Ÿ“‹ Automatic clipboard integration
  • ๐Ÿ“ค Pipe support for text input/output

๐Ÿ“ฆ Installation

go install github.com/0xEtherPunk/passgen@latest

# Optional: Create alias
echo 'alias pg="passgen"' >> ~/.bashrc # or zsh

๐ŸŽฏ Command Flags

Basic Flags

  • -l <number> - Set password length (default: random 24-28)
  • -o <file> - Save output to PNG file
  • -s <size> - Set QR code size in pixels (default: 256)

Encryption Flags

  • -e <text> - Encrypt text (requires -p)
  • -p <password> - Password for encryption/decryption
  • -d <file/text> - Decrypt from file or text

BIP39 Flags

  • -b - Generate BIP39 mnemonic (24 words by default)
  • -12 - Generate 12-word mnemonic (use with -b)

Language Flags (for BIP39)

  • -en - English wordlist (default)
  • -ru - Russian wordlist ๐Ÿ‡ท๐Ÿ‡บ
  • -jp - Japanese wordlist ๐Ÿ‡ฏ๐Ÿ‡ต
  • -cn - Chinese wordlist ๐Ÿ‡จ๐Ÿ‡ณ
  • -fr - French wordlist ๐Ÿ‡ซ๐Ÿ‡ท
  • -it - Italian wordlist ๐Ÿ‡ฎ๐Ÿ‡น
  • -ko - Korean wordlist ๐Ÿ‡ฐ๐Ÿ‡ท
  • -es - Spanish wordlist ๐Ÿ‡ช๐Ÿ‡ธ

Custom Flag

  • -c <text> - Create QR code from custom text

Examples

# Password generation
pg -l 32                    # 32-char password
pg -l 16 -o pass.png       # 16-char password with QR

# Encryption
pg -e secret -p pass   # Encrypt text
pg -d file.png -p pass   # Decrypt from file

# BIP39
pg -b                      # 24 words in English
pg -b -12 -ru             # 12 words in Russian
pg -b -jp -o seed.png     # Japanese with QR

๐Ÿ› ๏ธ Usage Examples

๐ŸŽฒ Password Generation

# Basic password (24-28 chars)
pg
pg -o pass.png           # Save as QR
pg -s 512 -o pass.png   # Custom QR size

# Custom length
pg -l 32
pg -l 16 -o pass.png

๐Ÿ” Encryption

Encryption

# Basic encryption
pg -e secret text -p password123
pg -e secret text -p password123 -o secret.png

# Multi-word text
pg -e this is my secret text -p pass123 -o secret.png

# Using generated password from clipboard
pg -o pass.png                   # Generate and save password
pg -e secret text -p "$(xclip)" -o secret.png

# Pipe input
echo "secret text" | pg -e -p "pass123"
cat file.txt | pg -e -p "pass123" -o encrypted.png

# Custom QR sizes
pg -e "secret" -p "pass" -o large.png -s 512
pg -e "secret" -p "pass" -o huge.png -s 1024

๐Ÿ”“ Decryption

# From QR file
pg -d secret.png -p "pass123"

# From encrypted text
pg -d "encrypted_base64_text" -p "pass123"

# Save decrypted to file
pg -d secret.png -p "pass123" > decrypted.txt

๐ŸŒ BIP39 Mnemonic Generation

# English (default)
pg -b            # 24 words
pg -b -12        # 12 words
pg -b -o mnemonic.png

# Other languages
pg -b -ru        # ๐Ÿ‡ท๐Ÿ‡บ Russian
pg -b -jp        # ๐Ÿ‡ฏ๐Ÿ‡ต Japanese
pg -b -cn        # ๐Ÿ‡จ๐Ÿ‡ณ Chinese
pg -b -fr        # ๐Ÿ‡ซ๐Ÿ‡ท French
pg -b -it        # ๐Ÿ‡ฎ๐Ÿ‡น Italian
pg -b -ko        # ๐Ÿ‡ฐ๐Ÿ‡ท Korean
pg -b -es        # ๐Ÿ‡ช๐Ÿ‡ธ Spanish

# Combined flags
pg -b -12 -ru -o mnemonic.png    # 12 Russian words with QR
pg -b -jp -s 512 -o phrase.png   # Japanese with large QR

๐Ÿ“ฑ QR Code Operations

# Custom text to QR
pg -c "any text" -o qr.png
pg -c "large text" -s 512 -o qr.png

# Read from QR
pg -d qr.png

๐Ÿ”„ Pipeline Examples

# Generate BIP39 and encrypt with clipboard password
pg -l 32                    # Generate and copy password
pg -b -12 -o seed.png | pg -e -p "$(xclip -o)" -o backup.png

# Or using xsel
pg -b -12 -o seed.png | pg -e -p "$(xsel -b)" -o backup.png

# For macOS:
pg -b -12 -o seed.png | pg -e -p "$(pbpaste)" -o backup.png

### ๐Ÿ”„ Advanced Usage
```bash
# Encrypt BIP39 phrase
pg -b -12 -o seed.png | pg -e -p "pass123" -o backup.png

# Create encrypted backup
tar czf - documents/ | \
  pg -e -p "pass123" -o backup.png -s 1024

๐ŸŽจ Creative Use Cases

# Secure BIP39 backup with encryption
pg -b -12 -o seed.png | pg -e -p "secret123" -o encrypted_seed.png -s 1000

# Multi-language secure backup
pg -b -12 -ru -o seed_ru.png | pg -e -p "ะฟะฐั€ะพะปัŒ123" -o backup_ru.png
pg -b -12 -jp -o seed_jp.png | pg -e -p "ใƒ‘ใ‚นใƒฏใƒผใƒ‰" -o backup_jp.png

# Create encrypted archive with seeds
mkdir seeds/
pg -b -12 -o seeds/en.png
pg -b -12 -ru -o seeds/ru.png
pg -b -12 -jp -o seeds/jp.png
tar czf - seeds/ | pg -e -p "archive123" -o seeds_backup.png -s 2000

# Secure password sharing
pg -l 32 -o pass.png | pg -e -p "share123" -o shared_pass.png
# Recipient can decrypt with: pg -d shared_pass.png -p "share123"

๐Ÿ” Tips & Tricks

  • ๐ŸŽฏ Generated passwords are automatically copied to clipboard
  • ๐Ÿ–ผ๏ธ QR codes are shown in terminal if no output file specified
  • ๐Ÿ“‹ Encrypted text is copied to clipboard for easy sharing
  • ๐Ÿ”„ Pipe support works with any text-producing command
  • ๐ŸŽจ Custom QR sizes help with scanning distance/resolution

๐Ÿ’ก Tips & Tricks

  • Generate and encrypt in one command using pipes
  • Use different QR sizes for different data lengths
  • Combine BIP39 languages for extra entropy
  • Store encryption keys as separate QR codes
  • Use generated passwords for encryption
  • Create multi-part backups for extra security

๐Ÿ—๏ธ Project Structure

passGen/
โ”œโ”€โ”€ cmd/
โ”‚   โ””โ”€โ”€ passgen/
โ”‚       โ””โ”€โ”€ main.go           # ๐ŸŽฏ Entry point
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ bip39/               # ๐ŸŽฒ BIP39 implementation
โ”‚   โ”‚   โ”œโ”€โ”€ wordlist/        # ๐ŸŒ Language wordlists
โ”‚   โ”‚   โ”œโ”€โ”€ bip39.go        
โ”‚   โ”‚   โ””โ”€โ”€ wordlist.go     
โ”‚   โ”œโ”€โ”€ crypto/              # ๐Ÿ”’ Encryption
โ”‚   โ”‚   โ””โ”€โ”€ xchacha.go       # XChaCha20-Poly1305
โ”‚   โ”œโ”€โ”€ clipboard/           # ๐Ÿ“‹ Clipboard operations
โ”‚   โ”œโ”€โ”€ generator/           # ๐ŸŽฏ Password generation
โ”‚   โ””โ”€โ”€ qr/                  # ๐Ÿ“ฑ QR code operations
โ””โ”€โ”€ README.md

โš™๏ธ Requirements

  • ๐Ÿ”ง Go 1.23.2 or higher
  • ๐Ÿง Unix-like system (for /dev/urandom)
  • ๐Ÿ“‹ xclip/xsel for Linux clipboard support
  • ๐Ÿ“‹ pbcopy/pbpaste for macOS clipboard support

๐Ÿ”’ Technical Details

Password Generation

  • Uses /dev/urandom for cryptographic randomness
  • Default length: 24-28 characters
  • Character set includes:
    • Lowercase letters (a-z)
    • Uppercase letters (A-Z)
    • Numbers (0-9)
    • Special characters (!@#$%^&*()_+-=[]{}|;:,.<>?)

BIP39 Implementation

  • Supports 8 languages: ๐Ÿ‡บ๐Ÿ‡ธ EN, ๐Ÿ‡ท๐Ÿ‡บ RU, ๐Ÿ‡ฏ๐Ÿ‡ต JP, ๐Ÿ‡จ๐Ÿ‡ณ CN, ๐Ÿ‡ซ๐Ÿ‡ท FR, ๐Ÿ‡ฎ๐Ÿ‡น IT, ๐Ÿ‡ฐ๐Ÿ‡ท KO, ๐Ÿ‡ช๐Ÿ‡ธ ES
  • 12 or 24 word phrases
  • Follows official BIP39 specification
  • Entropy: 128 bits (12 words) or 256 bits (24 words)

Encryption Details

  • Algorithm: XChaCha20-Poly1305
  • Unique salt for each encryption

QR Code Features

  • Default size: 256x256 pixels
  • Custom sizes supported
  • Supports both generation and reading
  • ASCII art display in terminal

๐ŸŒŸ If you find PassGen useful, please star it on GitHub!