smartpasslib-csharp
Smart Passwords Library for C#
Cryptographic password generation and management without storage. Cross-platform deterministic passwords for .NET applications.
Smart Passwords Library: Cryptographic password generation and management without storage. Generate passwords from secrets, verify knowledge without exposure, manage metadata securely.
Now with Cross-Platform Determinism: Same secret + same parameters = identical password on C#, Python, Go, Kotlin, JavaScript, Rust and any language with SHA-256.
Decentralized by Design: Unlike traditional password managers that store encrypted vaults on central servers, smartpasslib stores nothing. Your secrets never leave your device. Passwords are regenerated on-demand - no cloud, no database, no trust required.
No External Dependencies - Uses only System.Security.Cryptography.
- Zero-Storage Security - no passwords or secret phrases are ever stored or transmitted
- Decentralized Architecture - no central servers, no cloud dependency
- Cross-Platform Deterministic Generation - identical secret + parameters = identical password on any language
- Metadata Only - store only verification metadata (public keys, descriptions, lengths)
- On-Demand Regeneration - passwords are recalculated when needed
- Cryptographically Secure - uses SHA-256
- Decentralized & Serverless - no central database, no cloud lock-in
- Smart Password Generation - deterministic from secret phrase
- Public/Private Key System - 15-30 iterations for private key, 45-60 for public key
- Secret Verification - verify secret without exposing it
- Random Password Generation - cryptographically secure random passwords
- Authentication Codes - short codes for 2FA/MFA (4-100 chars)
- No External Dependencies - uses only System.Security.Cryptography
- Full Test Coverage - 100% tested for reliability and security
- Proof of Knowledge - public keys verify secrets without exposing them
- Decentralized Trust - no third party needed
- Deterministic Security - same input = same output, always reproducible across platforms
- Dynamic Iteration Counts - private key: 15-30, public key: 45-60
- Zero Storage of Secrets - secret phrases exist only in your memory
- No Recovery Backdoors - lost secret = permanently lost passwords
Validation Rules: Secret phrase: min 12 chars · Password length: 12-100 chars · Code: 4-100 chars
Key derivation (same as Python/JS/Kotlin/Go/Rust versions):
| 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
Decentralized Architecture:
- No central authority required
- Metadata can be synced via any channel (USB, cloud, even paper)
- Your security depends only on your secret phrase
- Works offline - no internet connection required
Copy SmartPassLib.cs to your project.
Generate Smart Password:
using SmartLegionLab.SmartPassLib; var secret = "MyStrongSecretPhrase2026!"; var length = 16; var password = SmartPasswordGenerator.GenerateSmartPassword(secret, length); Console.WriteLine(password);
Generate Public/Private Keys:
var secret = "MyStrongSecretPhrase2026!";
var publicKey = SmartPasswordGenerator.GeneratePublicKey(secret);
var privateKey = SmartPasswordGenerator.GeneratePrivateKey(secret);
Console.WriteLine($"Public Key (store locally): {publicKey}");
Console.WriteLine($"Private Key (never store): {privateKey}");
Verify Secret Against Public Key:
var secret = "MyStrongSecretPhrase2026!";
var storedPublicKey = "..."; // from local storage
var isValid = SmartPasswordGenerator.VerifySecret(secret, storedPublicKey);
if (isValid)
{
var password = SmartPasswordGenerator.GenerateSmartPassword(secret, 16);
}
Generate Random Passwords:
// Strong random (cryptographically secure) var strong = SmartPasswordGenerator.GenerateStrongPassword(20); // Base random var basePwd = SmartPasswordGenerator.GenerateBasePassword(16); // Authentication code (4-100 chars) var code = SmartPasswordGenerator.GenerateCode(8);
Metadata Manager:
var manager = new SmartPasswordManager(); var smartPassword = new SmartPassword(publicKey, "GitHub Account", 16); manager.AddSmartPassword(smartPassword); var retrieved = manager.GetSmartPassword(publicKey); manager.DeleteSmartPassword(publicKey);
Constants (SmartPasswordGenerator):
| Constant | Type | Description |
|---|---|---|
Version | string | Library version (4.0.0) |
Chars | string | Character set used for generation |
Methods (SmartPasswordGenerator):
| Method | Parameters | Returns | Description |
|---|---|---|---|
GeneratePrivateKey(secret) | secret: string | string | Private key (15-30 iterations) |
GeneratePublicKey(secret) | secret: string | string | Public key (45-60 iterations) |
VerifySecret(secret, publicKey) | secret, publicKey | bool | Verify secret matches public key |
GenerateSmartPassword(secret, length) | secret, length | string | Deterministic password |
GenerateStrongPassword(length) | length | string | Cryptographically random |
GenerateBasePassword(length) | length | string | Simple random password |
GenerateCode(length) | length | string | Short code (4-100 chars) |
Classes:
| Class | Description |
|---|---|
SmartPassword | Metadata container (PublicKey, Description, Length) |
SmartPasswordManager | Persistent storage for password metadata (JSON file) |
Input Validation:
| Parameter | Minimum | Maximum |
|---|---|---|
| Secret phrase | 12 chars | unlimited |
| Password length | 12 chars | 100 chars |
| Code length | 4 chars | 100 chars |
Secret Phrase Requirements:
- Minimum 12 characters (enforced)
- Case-sensitive
- Use mix of: uppercase, lowercase, numbers, symbols
- Never store digitally
- NEVER use your password description as secret phrase
Strong Secret Examples:
"MyStrongSecretPhrase2026!" - mixed case + numbers + symbols "P@ssw0rd!LongSecret" - special chars + numbers + length "GitHubPersonal2026!" - description + extra chars
Weak Secret Examples (avoid):
"short" - too short, raises exception "GitHub Account" - using description as secret (weak!) "password" - dictionary word, too short "1234567890" - only digits, too short
Decentralized Nature:
There is no "forgot password" button. This is by design:
- No central server can reset your passwords
- No support team can recover your access
- Your secret phrase is the ONLY key
This is the price of true decentralization - you are completely in control.
-
Pointer-Based Security Paradigm
- 10.5281/zenodo.17204738
Architectural Shift from Data Protection to Data Non-Existence -
Local Data Regeneration Paradigm
- 10.5281/zenodo.17264327
Ontological Shift from Data Transmission to Synchronous State Discovery
Same deterministic algorithm is available in multiple languages:
- smartpasslib - Python
- smartpasslib-js - JavaScript
- smartpasslib-kotlin - Kotlin
- smartpasslib-go - Go
- smartpasslib-rs - Rust
Core Libraries:
- smartpasslib - Python
- smartpasslib-js - JavaScript
- smartpasslib-kotlin - Kotlin
- smartpasslib-go - Go
- smartpasslib-csharp - C# (this)
- smartpasslib-rs - Rust
CLI Applications:
Desktop Applications:
- Desktop Manager (Python)
- Desktop Manager (C#)
- Desktop Manager (Rust, GUI)
- Desktop Manager (Rust, TUI)
Other:
By 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