A Zero Dependency, secure password generator and hasher for TypeScript/JavaScript applications.
- π Generate secure passwords with customizable options
- π Hash passwords using crypto's pbkdf2
- β‘ Synchronous and asynchronous methods
- π― Zero dependencies
- π Password strength assessment
- π‘οΈ Strict mode for guaranteed character inclusion
- π Salt generation and management
npm install passjenimport { Generator } from 'passjen';
// Generate a password with default options
const result = Generator.generate({});
console.log(result.password); // 6-character password
console.log(result.passwordStrength); // Password strength rating
// Generate a strong password
const strongPassword = Generator.generate({
characterLength: 12,
useNumbers: true,
useSymbols: true,
useLowercase: true,
useUppercase: true,
useStrict: true
});
// Generate a password excluding similar characters
const unambiguousPassword = Generator.generate({
characterLength: 10,
useNumbers: true,
useLowercase: true,
excludeSimilarCharacters: true // Excludes i, l, 1, L, o, 0, etc.
});import { Hasher } from 'passjen';
// Async hashing
const hashedResult = await Hasher.hash('myPassword');
console.log(hashedResult.hashedPassword);
console.log(hashedResult.salt);
// Sync hashing
const hashedResultSync = Hasher.hashSync('myPassword');
// Password comparison (async)
const isMatch = await Hasher.compare({
password: 'myPassword',
hashedPassword: hashedResult.hashedPassword,
salt: hashedResult.salt,
saltRounds: hashedResult.saltRounds
});
// Generate and hash a password in one step
const generatedHash = await Hasher.generateHashedPassword({
characterLength: 12,
useNumbers: true,
useSymbols: true,
useLowercase: true,
useUppercase: true,
useStrict: true,
saltRounds: 10
});| Option | Type | Default | Description |
|---|---|---|---|
| characterLength | number | 6 | Length of the generated password |
| useNumbers | boolean | false | Include numbers (0-9) |
| useSymbols | boolean | false | Include symbols (!@#$%^&*()_+-=[]{}|;:,.<>?) |
| useLowercase | boolean | false | Include lowercase letters (a-z) |
| useUppercase | boolean | false | Include uppercase letters (A-Z) |
| excludeSimilarCharacters | boolean | false | Exclude similar characters (ilLI|`oO0) |
| excludeTheseCharacters | string | "" | Custom characters to exclude |
| useStrict | boolean | false | Ensure at least one character from each selected type |
The password strength is calculated based on:
- Length (8+ chars for basic strength, 12+ for better strength)
- Character variety (numbers, lowercase, uppercase, symbols)
- Overall complexity
Strength levels:
- Too weak: Very short or simple passwords
- Weak: Longer passwords with limited character types
- Medium: Medium-length passwords with some character types
- Strong: Complex passwords with multiple character types and sufficient length
| Option | Type | Default | Description |
|---|---|---|---|
| saltRounds | number | 10 | Number of iterations for PBKDF2 |
| encryption | string | "sha256" | Hash algorithm to use |
PassJen uses Node's native crypto module with PBKDF2 for password hashing. The generator creates cryptographically secure random passwords when strict mode is enabled.
MIT License - see LICENSE file for details