npwg - Secure Password Generator
npwg is a secure password generator written in Rust. With npwg, you can easily generate strong and random passwords or passphrases to protect your online accounts.
Features
- Generate passwords with custom length and count
- Support various defined character sets
- Generate diceware passwords
- Generate pronounceable passwords
- Customizable password length, count, character sets, and separators
- Avoid repeating characters in passwords
- Display statistics about the generated passwords
- Show the estimated strength of the generated passwords
- Interactive mode for easy password generation
- Deterministic mode for password derivation from a master password and service
Installation
Using Cargo
If you have Rust and Cargo installed, you can install npwg using the following command:
This will download and compile the latest version of npwg and install it in your Cargo binary directory.
Manual Installation
- Make sure you have Rust installed on your system. If not, you can download it from the official Rust website: https://www.rust-lang.org/tools/install
- Clone this repository:
- Navigate to the project directory:
- Build the project:
- The executable can be found at
target/release/npwg.
Usage
Options
-l, --length <LENGTH>: Sets the length of the password [default: 16]-c, --count <COUNT>: Sets the number of passwords to generate [default: 1]--avoid-repeating: Avoid repeating characters in the password--stats: Show statistics about the generated passwords--strength: Show strength meter for the generated passwords-a, --allowed <CHARS>: Sets the allowed characters [default: allprint]--use-words: Use words instead of characters-i, --interactive: Start interactive console mode--separator <SEPARATOR>: Sets the separator for diceware passphrases (single character or 'random')--pronounceable: Generate pronounceable passwords--mutate: Mutate the passwords--mutation-type <TYPE>: Type of mutation to apply [default: replace]--mutation-strength <STRENGTH>: Strength of mutation [default: 1]--lengthen <INCREASE>: Increase the length of passwords during mutation--copy: Copy the generated password to the clipboard--qr: Print the generated passwords as QR codes--deterministic: Generate passwords deterministically from a master password and service-S, --service <SERVICE>: Service or context name used as salt for deterministic generation-u, --username <USERNAME>: Optional username for deterministic generation--counter <COUNTER>: Counter for deterministic generation [default: 1]-h, --help: Print help-V, --version: Print version
Predefined Character Sets
symbol1,symbol2,symbol3: Different sets of symbolsdigit: Numeric digitslowerletter: Lowercase lettersupperletter: Uppercase lettersshell: Shell-safe charactershomoglyph1tohomoglyph8: Various homoglyph setsslashes,brackets,punctuation: Specific character typesall,allprint,allprintnoquote, etc.: Various combinations of character types
Example Recipes
Quick Passwords
Generate default credentials:
Specify length, count, and character sets:
Inspect entropy and statistics in one pass:
Copy freshly generated secrets to the clipboard:
Render passwords as QR codes (one per password):
Diceware Passphrases
First run downloads and verifies the EFF wordlist automatically. Generate six-word phrases separated by spaces:
Customise separators or request random punctuation between words:
Pronounceable and Pattern Modes
Create pronounceable strings that alternate consonants and vowels:
Enforce structural patterns (L=letter, D=digit, S=symbol):
Mutation Workflow
Tweak existing passwords by applying deterministic mutations and optional lengthening:
Deterministic Mode
Derive a stable password from a master password and service context (no randomness):
Include an optional username and counter to create distinct variants:
Use interactive mode for guided generation and mutation prompts:
Configuration Profiles
Create a config.toml in ~/.config/npwg/ (or ~/.npwg/ on systems without XDG directories) to store defaults and reusable profiles:
[]
= 20
= "upperletter,lowerletter,digit"
[]
= 5
= true
= "-"
Invoke a profile at runtime:
Provide a custom config path when needed:
Use built-in policies for common compliance regimes; these enforce minimum length and character-set expectations before applying your overrides:
Contributing
Contributions are welcome! If you find a bug or have a suggestion for improvement, please open an issue or submit a pull request.
When contributing Rust code, include only the SPDX license header at the top of each *.rs file—avoid additional inline or block comments elsewhere.
License
This project is licensed under the MIT License.