Smart Passwords Library for Rust
Cryptographic password generation and management without storage. Cross-platform deterministic passwords for Rust applications.
Smart Passwords Library: Cryptographic password generation and management without storage. Generate passwords from secrets, verify knowledge without exposure.
Cross-Platform Determinism: Same secret + same parameters = identical password on Rust, C#, Python, Kotlin, Go, JavaScript.
Decentralized by Design: No cloud, no database, no trust required.
No External Dependencies — Pure Rust, uses standard crypto.
rand crateKey derivation (same as Python/JS/Kotlin/Go/C# versions v4.0.0):
| Key Type | Iterations | Purpose |
|---|---|---|
| Private Key | 15-30 (dynamic) | Password generation (never stored, never transmitted) |
| Public Key | 45-60 (dynamic) | Verification (stored locally) |
Character Set:
!@#$%^&*()_+-=[]{};:,.<>?/ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz
Validation Rules:
Add to your Cargo.toml:
[dependencies] smartpasslib = "4.0"
Generate Smart Password:
use smartpasslib::generate_smart_password_sync;
let secret = "MyStrongSecretPhrase2026!";
let password = generate_smart_password_sync(secret, 16).unwrap();
println!("{}", password);
Generate Public/Private Keys:
use smartpasslib::{generate_private_key, generate_public_key};
let secret = "MyStrongSecretPhrase2026!";
let public_key = generate_public_key(secret).unwrap();
let private_key = generate_private_key(secret).unwrap();
Verify Secret:
use smartpasslib::{generate_public_key, verify_secret};
let secret = "MyStrongSecretPhrase2026!";
let stored_public_key = "...";
let is_valid = verify_secret(secret, &stored_public_key).unwrap();
Generate Random:
use smartpasslib::{generate_strong_password, generate_code};
let strong = generate_strong_password(20).unwrap();
let code = generate_code(8).unwrap();
Metadata Manager:
use smartpasslib::{SmartPasswordManager, SmartPassword};
let mut manager = SmartPasswordManager::new().unwrap();
let sp = SmartPassword::new(public_key, "GitHub".to_string(), 16).unwrap();
manager.add(sp).unwrap();
let retrieved = manager.get(&public_key).unwrap();
manager.delete(&public_key).unwrap();
Constants:
| Constant | Type | Description |
|---|---|---|
VERSION | &str | Library version (4.0.0) |
CHARS | &str | Character set used for generation |
Functions:
| Function | Parameters | Returns | Description |
|---|---|---|---|
generate_private_key(secret) | secret: &str | Result<String, Error> | Private key (15-30 iterations) |
generate_public_key(secret) | secret: &str | Result<String, Error> | Public key (45-60 iterations) |
verify_secret(secret, public_key) | secret, public_key | Result<bool, Error> | Verify secret matches public key |
generate_smart_password_sync(secret, length) | secret, length | Result<String, Error> | Deterministic password |
generate_strong_password(length) | length: usize | Result<String, Error> | Cryptographically random |
generate_base_password(length) | length: usize | Result<String, Error> | Simple random password |
generate_code(length) | length: usize | Result<String, Error> | Short code (4-100 chars) |
Classes:
| Class | Description |
|---|---|
SmartPassword | Metadata container (public_key, description, length) |
SmartPasswordManager | Persistent storage for password metadata (JSON file) |
The same deterministic algorithm is available in multiple languages. SmartPassLib Rust produces identical passwords to:
| Language | Repository |
|---|---|
| Python | smartpasslib |
| JavaScript | smartpasslib-js |
| Kotlin | smartpasslib-kotlin |
| Go | smartpasslib-go |
| C# | smartpasslib-csharp |
| Rust | smartpasslib-rs (this) |
Core Libraries:
CLI Applications:
Desktop Applications:
Other:
git clone https://github.com/smartlegionlab/smartpasslib-rs cd smartpasslib-rs cargo build cargo test cargo run --example demo cargo bench cargo doc --open
Commands:
cargo check — Compilation checkcargo test — Run testscargo run --example demo — Run democargo bench — Run benchmarkscargo doc --open — Documentationcargo fmt — Formatcargo clippy — LinterBy using this software, you agree to the full disclaimer terms.
Software provided "AS IS" without warranty. You assume all risks.
Full legal disclaimer: See DISCLAIMER.md
License: BSD 3-Clause License