secure-passgen
§1NAME
secure-passgen — military-grade, fool-proof, international (i18n) password generator and LibreOffice/Excel-compatible CSV database creator, written in Rust with a plugin architecture and Deep-Entropy (SHA-512 hash-chaining) engine.
§2SYNOPSIS
secure-passgen [OPTIONS] [COUNT] [-COUNT_SHORTHAND]
secure-passgen -c -n -s -l 16 -1M -o database.csv
secure-passgen --password-db --charset chinese -c -n -2500 -o grid.csv
secure-passgen --language hu --charset hu -c -n -s --extreme-random -l 20
secure-passgen --plugins uppercase,hyphen -c -n -100K -o bulk.csv
§3DESCRIPTION
secure-passgen generates cryptographically secure passwords using the operating system's CSPRNG (getrandom: Linux getrandom(2) syscall, macOS getentropy(2), Windows BCryptGenRandom). It re-implements and extends the classic pwgen(1) tool with modern safety guarantees:
🛡️ Fool-proof design
The program never aborts on user errors. Every problem (existing file, unwritable directory, invalid number, empty charset) is automatically corrected and reported in a final "AUTOMATIC FIXES APPLIED" panel.
🌍 International (i18n)
20 UI languages for all console messages and 20 Unicode character sets (Latin, Magyar, 中文, 日本語, 한국어, العربية, עברית, हिन्दी, বাংলা, ไทย, Ελληνικά, Кириллица, Հայերեն, ქართული, தமிழ், తెలుగు, ಕನ್ನಡ, മലയാളം, ਪੰਜਾਬੀ, සිංහල).
🧠 Deep Entropy engine
Optional SHA-512 hash-chaining mode: each password seed is re-hashed up to 1,000,000 iterations so every character derives from the "millionth" cryptographic operation, not the first.
💾 Streaming memory model
Passwords are generated one-by-one and streamed through an 8 KB BufWriter. Memory stays at ~2.7 MB whether you generate 10 or 1,000,000 passwords. Verified by Valgrind: 0 bytes lost.
🔌 Plugin architecture
Trait-based plugin system (Plugin trait). Two reference plugins ship with the binary: uppercase and hyphen. New plugins require ~20 lines of Rust.
📊 Database Grid mode
--password-db produces a spreadsheet grid with Excel-style column headers (Row,A,B,...,ZZ,AAA...) up to 1000 rows, directly importable into LibreOffice Calc / Excel.
§4OPTIONS
4.1 Password style (pwgen-compatible)
| Option | Description |
|---|---|
-c, --capitals | Include capital letters (A-Z, and uppercase variants of the selected script). |
-n, --numbers | Include digits 0-9. |
-s, --symbols | Include symbols !@#$%^&*()-_=+[]{}|;:,.<>? |
-B, --no-ambiguous | Exclude visually ambiguous characters 1 l I 0 O o. |
4.2 Generation
| Option | Description | Default |
|---|---|---|
-l, --length <N> | Password length, 1–16000 (OpenSSL-class maximum). | 8 |
--count <N> | Number of passwords. | 10 |
-5, -250, -100K, -1M | Hyphen shorthand count (pre-processed before the CLI parser, so it can never swallow other flags). | — |
--extreme-random | Enable Deep Entropy SHA-512 hash-chaining per password. | off |
--extreme-iter <N> | Hash iterations per password, 1000–1000000. | 10000 |
4.3 Output & database
| Option | Description |
|---|---|
-o, --output <file> | Output CSV path (relative or absolute). |
--password-db | Database Grid mode with Excel column letters. |
--auto-rename | If the target file exists, write name_1.csv, name_2.csv… (default ON). |
--timestamp | Append YYYYMMDD_HHMMSS to the filename instead of a counter. |
--log <file> | Metadata log (time, system, fixes). Never logs passwords. |
4.4 International & system
| Option | Description |
|---|---|
--language <code> | UI language: en hu es zh hi ar bn pt ru ja de fr ko tr vi it pl uk nl ro (or auto). |
--charset <code> | Password character set: latin hu zh ja ko ar he hi bn th el ru hy ka ta te kn ml pa si. |
--plugins <list> | Comma-separated plugin list: uppercase, hyphen. |
--debug | Verbose internal diagnostics on stderr. |
-h, --help / -V, --version | Help / version. |
§5CHARACTER SETS (live samples)
The samples below were generated by this binary at documentation build time (12 characters each):
| Flag | Live generated sample |
|---|---|
--charset latin | dolxlccvxjjr |
--charset hungarian | cahoékpűayei |
--charset chinese | 们学们也种说能的生是子能 |
--charset japanese | オほニすエエノサヌれアウ |
--charset korean | 버투터사주라오버서수사터 |
--charset arabic | ضجفشفكخصزثظظ |
--charset hebrew | להקפסאגרקדזפ |
--charset hindi | उथटओढउअनगनपऔ |
--charset bengali | ঘধসঐগদতওউতদঠ |
--charset thai | ฒซกนลฟพมทญอญ |
--charset greek | εκπταοχσβαοχ |
--charset cyrillic | беёужжвъищбй |
--charset armenian | նգխնժէնղվնխճ |
--charset georgian | ძლთშოყღჩჩბძბ |
--charset tamil | ஞனஞஉரடசவஒவவவ |
--charset telugu | షనకఇడఔగసఞణమజ |
--charset kannada | ರಙಧಏಕನಛಋಈಐಜಯ |
--charset malayalam | ഭജശഋടഎലഷഎആഷഈ |
--charset gurmukhi | ਚਪਭਹਯਅਥਦਅਹਓਠ |
--charset sinhala | දවඪඡණලකඳඵඌඬඌ |
§6UI LANGUAGES
All console banners, progress labels, success messages and the auto-recovery panel are translated. Detected automatically from $LANG, overridable with --language. Supported: English, Magyar, Español, 中文, हिन्दी, العربية, বাংলা, Português, Русский, 日本語, Deutsch, Français, 한국어, Türkçe, Tiếng Việt, Italiano, Polski, Українська, Nederlands, Română.
§7DEEP ENTROPY ENGINE
1. seed = 64 bytes from OS CSPRNG (getrandom syscall)
2. for i in 0..iterations: # up to 1,000,000
seed = SHA512(seed || i.to_le_bytes())
3. for each character position p:
index = u16(seed[2p], seed[2p+1]) mod charset_len
password[p] = charset[index]
§8MEMORY ARCHITECTURE
- Streaming write: one password lives in memory at a time, then Rust ownership drops it deterministically.
- BufWriter (8 KB): syscalls are batched; 100K passwords produce a handful of writes.
- Periodic flush: every 1000 rows, so a crash never loses more than 1000 rows.
- Constant RSS: 2.6–2.8 MB measured from 10 to 100,000 passwords (see benchmarks).
- Valgrind clean: 0 bytes definitely/indirectly/possibly lost.
§9PLUGIN SYSTEM (developer guide)
// src/plugins/my_plugin.rs (~20 lines)
use super::Plugin;
pub struct MyPlugin;
impl Plugin for MyPlugin {
fn name(&self) -> &str { "MyPlugin" }
fn description(&self) -> &str { "Does something custom" }
fn process_password(&self, password: String) -> String {
password.to_uppercase() // any transformation
}
}
Register it in src/plugins/mod.rs and in load_plugins() in main.rs, then use --plugins myplugin. Future roadmap: dynamic .so loading via libloading and WASM plugins.
§10AUTO-RECOVERY (fool-proof engine)
| Problem detected | Automatic solution | Severity |
|---|---|---|
| Output file already exists | Writes name_1.csv … name_9999.csv, then timestamp name | ⚠ Warning |
| Directory not writable | Falls back to /tmp, then $HOME; real path printed | ⚠ Critical |
| Empty character set | Restores the full base charset of the selected script | ⚠ Critical |
| Length < 1 or > 16000 | Clamped to 8 / 16000 | ⚠ Warning |
| Count < 1 | Reset to 10 | ⚠ Warning |
| Unknown --language / --charset | Falls back to system language / Latin | ⚠ Warning |
Every applied fix is listed in the final yellow panel, so soldiers and beginners always see what happened and where the file really is.
§11BENCHMARKS (measured on this host)
Values injected from the latest benchmarks_*/results.csv run on this machine:
| Test | Result |
|---|---|
| Maximum throughput (100K passwords, 16 chars) | 12,241,316 pw/s |
| Hyperfine mean ± σ (10K passwords, 10 runs) | 9.3 ms ± 1.2 ms |
| Memory (10 → 100K passwords) | 2.6–2.8 MB constant |
| Valgrind leak check | 0 bytes lost (544 B still-reachable = Rust runtime) |
| Deep Entropy 1K / 10K / 100K iter | 8,210 / 2,143 / 138 pw/s |
| Unicode charsets (6 scripts) | all OK, ~11–12K pw/s |
| Test suite | 25/25 passed |
§12EXAMPLES
./secure-passgen -c -n -s -l 16 -1M -o million.csv [########################################] 100% (1000000/1000000) SUCCESS - Operation completed successfully 0.082 seconds File saved to /home/boldwelder/secure-passgen/million.csv
./secure-passgen --password-db --charset chinese -c -n -2500 -o grid.csv Mode: Password Database Grid | Columns: A B C | Rows: 1000 SUCCESS # open with: libreoffice --calc grid.csv
./secure-passgen -c -n -s -o same.csv # run twice ⚠ AUTOMATIC RECOVERY ACTIVATED — Problems found: 1 ║ Fix #1 Problem: File 'same.csv' already exists ║ Solution: Auto-renamed to 'same_1.csv'
§13BEGINNER GUIDE
- Build once:
cargo build --release - Generate your first safe passwords:
./target/release/secure-passgen -c -n -s -l 16 -50 -o my.csv - Double-click
my.csv→ opens in LibreOffice Calc / Excel. - If anything goes wrong, read the yellow panel at the end — it tells you exactly what the program fixed and where your file is.
§14ADVANCED GUIDE
- Combine Deep Entropy with plugins:
--extreme-random --extreme-iter 100000 --plugins uppercase,hyphen - Generate a Hungarian-charset vault:
--language hu --charset hu -c -n -s -B -l 20 -10K - Audit run with metadata log:
--debug --log audit.log(passwords are never logged). - Re-run the full QA suite any time with
./patch_and_benchmark.sh.
§15SECURITY NOTES
shred), and never commit them to Git.- Entropy source: OS kernel CSPRNG only; no
rand(), no time-based seeds. - No network access, no telemetry, no logging of secrets by design.
- Unicode passwords increase entropy per character (larger alphabet), but verify the target system accepts UTF-8 input.
§16FILES
~/.cargo/bin or ./target/release/secure-passgen binary
./passwords.csv default output
./benchmarks_*/results.csv QA results
./documentation_v2/README.html this manual
§17SEE ALSO
pwgen(1), openssl-rand(1), getrandom(2), apg(1), makepasswd(1), NIST SP 800-90A (DRBG), RFC 4180 (CSV).
§18AUTHORS
Boldwelder (micro-electric technician, welder, ex-diplomat MFA, 4-generation Hungarian military family) — concept, requirements, QA. Adjutans-1 — Rust architecture & implementation.
§19CHANGELOG
| Version | Change |
|---|---|
| 3.0.2 | FIXED: hyphen shorthand no longer swallows following flags; FIXED: case-less Unicode scripts (CJK/Arabic/Hindi…) now included by default; docs v2. |
| 3.0.1 | Removed unused import; warning-free build. |
| 3.0.0 | Fool-proof auto-recovery, 20 UI languages, 20 Unicode charsets, plugin system. |
| 2.0.0 | Rust rewrite: CSPRNG, Deep Entropy, streaming CSV, grid mode. |
| 1.x | Original bash prototype (pwgen-compatible). |