Cryptographically secure password and passphrase generation utilities with comprehensive strength analysis. Built with TypeScript and leveraging the Web Crypto API for maximum security.
✅ Cryptographically Secure - Uses Web Crypto API with rejection sampling to eliminate modulo bias
✅ Password Generation - Configurable length (8-128 chars) with customizable character sets
✅ Passphrase Generation - Diceware-based with 384-word EFF wordlist subset
✅ Breach Checking - HIBP integration with k-Anonymity protocol (privacy-preserving)
✅ Strength Analysis - Powered by zxcvbn (lazy-loaded) with detailed feedback
✅ Argon2id Hashing - OWASP-recommended password hashing with Web Workers
✅ Policy Validation - NIST 800-63B compliance checking
✅ Quick Validation - Lightweight real-time password checking
✅ TypeScript First - Full type definitions and IntelliSense support
✅ Framework Integrations - React hooks, Web Component, CLI tool
✅ Tree Shakeable - Optimized bundle size with ESM and CommonJS support
npm install password-suiteyarn add password-suitepnpm add password-suiteimport { generatePassword } from 'password-suite';
const result = generatePassword({
length: 16,
includeUppercase: true,
includeLowercase: true,
includeNumbers: true,
includeSymbols: true
});
console.log(result.password); // "Kp9$mNz2@Qw5Xr8T"
console.log(result.strength); // "very-strong"
console.log(result.entropy); // 95.2import { generatePassphrase } from 'password-suite';
const result = generatePassphrase({
wordCount: 5,
separator: 'dash',
capitalization: 'first',
includeNumber: true
});
console.log(result.password); // "Forest-Mountain-River-Sky-Ocean47"
console.log(result.entropy); // 67.2import { analyzePasswordStrength } from 'password-suite';
const analysis = analyzePasswordStrength("password123");
console.log(analysis.score); // 12
console.log(analysis.strength); // "weak"
console.log(analysis.crackTime); // "instant"
console.log(analysis.suggestions); // ["Add more unique characters", ...]
console.log(analysis.weaknesses); // ["Common password", "Predictable sequence"]import { quickStrengthCheck } from 'password-suite';
const check = quickStrengthCheck(userInput);
console.log(check.feedback); // "Password is too short"
console.log(check.score); // 25
console.log(check.strength); // "weak"Install the React hooks package:
npm install password-suite-reactimport { usePasswordGenerator, usePasswordStrength } from 'password-suite-react';
function PasswordForm() {
const { password, generate, loading } = usePasswordGenerator({ length: 20 });
const { strength } = usePasswordStrength(password, { debounce: 300 });
return (
<div>
<button onClick={() => generate()} disabled={loading}>
Generate Password
</button>
<input type="text" value={password} readOnly />
{strength && <StrengthMeter score={strength.score} />}
</div>
);
}Available Hooks:
usePasswordGenerator- Generate passwords with state managementusePasswordStrength- Real-time strength analysis with debouncingusePassphraseGenerator- Generate passphrasesuseBreachCheck- Check passwords against HIBP database
Install the Web Component package:
npm install password-suite-web-componentWorks with any framework or vanilla HTML:
<script type="module">
import 'password-suite-web-component';
</script>
<password-generator
length="20"
include-symbols="true"
auto-generate="false">
</password-generator>
<script>
const generator = document.querySelector('password-generator');
generator.addEventListener('password-generated', (e) => {
console.log('Password:', e.detail.password);
console.log('Strength:', e.detail.strength);
});
</script>Features:
- ✅ Framework-agnostic (works everywhere)
- ✅ Shadow DOM for style encapsulation
- ✅ Full keyboard accessibility (WCAG 2.1 Level AA)
- ✅ Dark mode support
- ✅ Custom events for integration
📖 Full Web Component Documentation
Install globally or use with npx:
# Global install
npm install -g password-suite-cli
# Or use with npx (no install required)
npx password-suite generateCommands:
# Generate password
password-suite generate --length 32 --count 5
# Generate passphrase
password-suite passphrase --words 6 --separator dash
# Analyze password strength
password-suite analyze "MyP@ssw0rd123"
# Check for breaches
password-suite breach "password123"
# Quick strength check
password-suite quick "abc123"
# JSON output
password-suite generate --jsonFeatures:
- ✅ Auto-copy to clipboard (30s timeout)
- ✅ Colorized terminal output
- ✅ JSON output for scripting
- ✅ Batch generation
- ✅ Cross-platform (macOS, Linux, Windows)
Generates a cryptographically secure password.
Options:
interface PasswordGeneratorOptions {
length?: number; // 8-128 (default: 16)
includeUppercase?: boolean; // default: true
includeLowercase?: boolean; // default: true
includeNumbers?: boolean; // default: true
includeSymbols?: boolean; // default: true
excludeAmbiguous?: boolean; // Exclude 0, O, l, 1, I (default: false)
customCharset?: string; // Custom character set (overrides other options)
}Returns:
interface GeneratedPassword {
password: string;
entropy: number;
strength: 'weak' | 'medium' | 'strong' | 'very-strong';
}Generate multiple passwords at once (1-100).
Generate a memorable password with alternating consonants and vowels.
Returns secure default configuration.
Generates a Diceware-based passphrase.
Options:
interface PassphraseOptions {
wordCount?: number; // 4-8 words (default: 5)
separator?: 'dash' | 'space' | 'symbol' | 'none'; // default: 'dash'
capitalization?: 'none' | 'first' | 'all' | 'random'; // default: 'none'
includeNumber?: boolean; // default: false
}Pre-configured for maximum memorability.
Returns secure default configuration.
Comprehensive password strength analysis using zxcvbn.
Returns:
interface PasswordStrengthResult {
score: number; // 0-100
strength: string; // weak | medium | strong | very-strong
entropy: number; // Bits of entropy
crackTime: string; // Human-readable estimate
warning: string | null; // Primary warning
suggestions: string[]; // Improvement suggestions
weaknesses: string[]; // Detected issues
}Detects:
- Common passwords and dictionary words
- Keyboard patterns (qwerty, asdf)
- Repeated sequences (aaa, 123)
- Date patterns and years
- Personal information patterns
Lightweight real-time validation (no zxcvbn overhead).
Returns:
interface QuickStrengthResult {
score: number; // 0-100
strength: string; // weak | medium | strong | very-strong
feedback: string; // User-friendly message
weaknesses: string[]; // Basic issues
}Check if password meets baseline requirements.
Returns:
interface MinimumRequirementsResult {
meets: boolean;
missingRequirements: string[];
}Format 6-digit TOTP codes with space separator.
formatTOTPCode("123456") // Returns: "123 456"- Random Generation: Uses
crypto.getRandomValues()from Web Crypto API - No Bias: Implements rejection sampling to eliminate modulo bias
- Entropy Calculation: Accurate mathematical entropy: log₂(charset_size^length)
- No Predictable Patterns: True random generation, not pseudo-random
| Strength | Entropy | Use Case |
|---|---|---|
| Weak | < 40 bits | ❌ Not recommended |
| Medium | 40-59 bits | |
| Strong | 60-79 bits | ✅ Standard accounts |
| Very Strong | ≥ 80 bits | ✅ High-security accounts |
- Use Strong Passwords: Minimum 16 characters with all character types
- Use Passphrases: For memorability, use 5+ words with separators
- Avoid Patterns: Don't use keyboard patterns, dates, or personal info
- Unique Passwords: Never reuse passwords across services
- Regular Updates: Change passwords periodically for critical accounts
Full TypeScript definitions included. Import types directly:
import type {
PasswordGeneratorOptions,
GeneratedPassword,
PassphraseOptions,
PasswordStrengthResult,
QuickStrengthResult,
MinimumRequirementsResult
} from 'password-suite';- Core library: ~30KB gzipped
- With zxcvbn: ~400KB gzipped (lazy loaded)
- Types: ~5KB
The library uses tree-shaking, so you only bundle what you import.
Requires browsers with Web Crypto API support:
- Chrome/Edge 37+
- Firefox 34+
- Safari 11+
- Opera 24+
- Node.js 20+
import { useState, useCallback } from 'react';
import { generatePassword, analyzePasswordStrength } from 'password-suite';
function usePasswordGenerator() {
const [password, setPassword] = useState('');
const [analysis, setAnalysis] = useState(null);
const generate = useCallback(() => {
const result = generatePassword({ length: 16 });
setPassword(result.password);
setAnalysis(analyzePasswordStrength(result.password));
}, []);
return { password, analysis, generate };
}import { quickStrengthCheck, meetsMinimumRequirements } from 'password-suite';
function validatePassword(password: string): string | null {
const requirements = meetsMinimumRequirements(password);
if (!requirements.meets) {
return requirements.missingRequirements.join(', ');
}
const check = quickStrengthCheck(password);
if (check.strength === 'weak') {
return 'Password is too weak. ' + check.feedback;
}
return null; // Valid
}import { generatePasswords } from 'password-suite';
// Generate 10 passwords for testing
const passwords = generatePasswords(10, {
length: 20,
includeSymbols: true
});
passwords.forEach(p => {
console.log(`${p.password} (${p.strength}, ${p.entropy.toFixed(1)} bits)`);
});The library includes comprehensive test coverage:
npm test # Run tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportTest categories:
- Security tests (randomness quality, bias detection)
- Functional tests (feature correctness)
- Integration tests (end-to-end workflows)
- Edge case tests (boundary conditions)
# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm test
# Type checking
npm run type-check
# Linting
npm run lintContributions are welcome! Please follow these guidelines:
- Security First - Never compromise cryptographic integrity
- Tests Required - All new features must include tests
- Type Safety - Full TypeScript coverage required
- Documentation - Update README and JSDoc comments
- No Breaking Changes - Follow semantic versioning
See AGENTS.md for detailed development guidelines.
Apache License 2.0 - see LICENSE file for details.
- zxcvbn - Password strength estimation by Dropbox
- @noble/hashes - Cryptographic primitives by Paul Miller
- EFF Wordlist - Diceware wordlist by Electronic Frontier Foundation
- Landing Page: https://ian-p1nt0.github.io/password-suite/
- Issues: GitHub Issues
- Repository: GitHub
- NPM: password-suite
- Sponsor: GitHub Sponsors 💖
Made with ❤️ by TrustVault Team