Smart Passwords Library for JavaScript
Cryptographic password generation and management without storage. Cross-platform deterministic passwords with Web Crypto API.
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 JavaScript, C#, Python, Go, Kotlin 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.
⚠️ Breaking Change (v4.0.0)
This version is NOT backward compatible with v1.x.x. Passwords generated with older versions cannot be regenerated with v4.0.0.
📖 Full migration instructions → see MIGRATION.md
Validation Rules: Secret phrase: min 12 chars · Password length: 12-100 chars · Code: 4-100 chars
Key derivation (same as Python/C#/Go/Kotlin 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
Decentralized Architecture:
Just copy smartpasslib.js to your project and include it:
<script src="path/to/smartpasslib.js"></script>
Generate Smart Password:
const secret = "MyStrongSecretPhrase2026!"; const length = 16; const password = await SmartPassLib.generateSmartPassword(secret, length); console.log(password);
Generate Public/Private Keys:
const secret = "MyStrongSecretPhrase2026!";
const publicKey = await SmartPassLib.generatePublicKey(secret);
const privateKey = await SmartPassLib.generatePrivateKey(secret);
console.log('Public Key (store locally):', publicKey);
console.log('Private Key (never store):', privateKey);
Verify Secret Against Public Key:
const secret = "MyStrongSecretPhrase2026!";
const storedPublicKey = "..."; // from local
const isValid = await SmartPassLib.verifySecret(secret, storedPublicKey);
if (isValid) {
const password = await SmartPassLib.generateSmartPassword(secret, 16);
}
Generate Random Passwords:
// Strong random (cryptographically secure) const strong = await SmartPassLib.generateStrongPassword(20); // Base random const base = await SmartPassLib.generateBasePassword(16); // Authentication code (4-100 chars) const code = await SmartPassLib.generateCode(8);
Properties:
| Property | Type | Description |
|---|---|---|
VERSION | string | Library version (4.0.0) |
CHARS | string | Character set used for generation |
Methods:
| Method | Parameters | Returns | Description |
|---|---|---|---|
generatePrivateKey(secret) | secret: string | Promise<string> | Private key (15-30 iterations) |
generatePublicKey(secret) | secret: string | Promise<string> | Public key (45-60 iterations) |
verifySecret(secret, publicKey) | secret, publicKey | Promise<boolean> | Verify secret matches public key |
generateSmartPassword(secret, length) | secret, length | Promise<string> | Deterministic password |
generateStrongPassword(length) | length | Promise<string> | Cryptographically random |
generateBasePassword(length) | length | Promise<string> | Simple random password |
generateCode(length) | length | Promise<string> | Short code (4-100 chars) |
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:
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:
This is the price of true decentralization — you are completely in control.
Same deterministic algorithm is available in multiple languages:
Core Libraries:
CLI Applications:
Desktop Applications:
Other:
Open test.html in your browser to run the test suite.
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