Secure, zero-dependency cryptographic library with universal runtime support
Zero dependencies โข Production ready โข Universal compatibility
Works seamlessly across Node.js, CloudFlare Workers, and Browser environments with automatic optimization.
WebCrypto API provides 2-15x performance boost. Smart factory pattern selects optimal implementation.
Timing attack resistant, NIST-compliant algorithms, sanitized error handling, zero dependencies.
85 comprehensive tests including NIST test vectors, >95% coverage, cross-environment validation.
Production build has zero dependencies for minimal attack surface and easy auditing.
Comprehensive type definitions, type-safe APIs, full IntelliSense support across all environments.
Native crypto module
๐ฅ๐ฅ๐ฅ Fastest performance
Perfect for servers & CLI tools
WebCrypto API
๐ฅ๐ฅ High performance
Edge computing optimized
WebCrypto API
๐ฅ๐ฅ High performance
Client-side encryption
import { cryptoServiceFactory, DEFAULT_KEY_DERIVATION_PARAMS } from 'password-manager-crypt';
// Automatic environment detection and optimal performance
const cryptoService = cryptoServiceFactory.createForPerformance('high');
// Encrypt vault data
async function encryptVault(masterPassword: string, vaultData: string) {
const salt = cryptoService.generateSalt();
const key = await cryptoService.deriveKey(
masterPassword,
salt,
DEFAULT_KEY_DERIVATION_PARAMS
);
const encryptedData = await cryptoService.encrypt(
new TextEncoder().encode(vaultData),
key
);
return { encryptedData, salt };
}
// Decrypt vault data
async function decryptVault(masterPassword: string, salt: Uint8Array, encryptedData: EncryptedData) {
const key = await cryptoService.deriveKey(masterPassword, salt, DEFAULT_KEY_DERIVATION_PARAMS);
const decryptedBytes = await cryptoService.decrypt(encryptedData, key);
if (!decryptedBytes) {
return null; // Invalid password or tampered data
}
return new TextDecoder().decode(decryptedBytes);
}