A modern, privacy-first password generator and vault application with client-side AES-256 encryption, built with Next.js 15, TypeScript, and MongoDB.
with2fa.1.mp4
without2fa.mp4
- Customizable Length: 4-64 characters with slider control
- Character Types: Uppercase, lowercase, numbers, symbols
- Exclude Ambiguous: Option to exclude 0/O, 1/l/I characters
- Real-time Strength: Visual password strength indicator (Weak/Medium/Strong)
- One-Click Copy: Copy to clipboard with visual feedback
- Auto-Clear: Clipboard automatically clears after 15 seconds for security
- Quick Save: Direct "Save to Vault" button
- Client-Side Encryption: AES-256-CBC encryption before data leaves browser
- Zero-Knowledge: Server never sees plaintext passwords
- Full CRUD: Create, Read, Update, Delete vault items
- Rich Fields: Title, username, password, URL, notes
- Tags System: Organize items with multiple tags
- Search & Filter: Real-time search across all fields
- Show/Hide Passwords: Toggle password visibility
- Copy Protection: Auto-clear clipboard after 15 seconds
- Encryption Key Validation: Verifies correct key before decryption
- Email/Password Auth: Secure user registration and login
- Password Hashing: bcrypt with salt rounds for password storage
- JWT Tokens: httpOnly cookies with secure token management
- 2FA (TOTP): Time-based One-Time Password with QR code
- Vault Access Control: Requires password + 2FA verification to access vault
- Session Management: Encryption key stored only in memory (cleared on logout)
- Protection: CSRF protection, XSS prevention, secure headers
- Theme Toggle: Beautiful dark/light mode with smooth transitions
- Animations: Framer Motion for smooth, professional animations
- Responsive Design: Mobile-first, works on all screen sizes
- Loading States: Skeleton loaders and spinners
- Error Handling: User-friendly error messages
- Accessibility: ARIA labels, keyboard navigation
- Custom Modals: Beautiful confirmation dialogs for delete/2FA
password-generator/
βββ app/
β βββ api/ # API Routes
β β βββ auth/ # Authentication endpoints
β β β βββ signin/route.ts # User login
β β β βββ signup/route.ts # User registration
β β β βββ logout/route.ts # User logout
β β β βββ enable-2fa/route.ts # Generate 2FA secret
β β β βββ verify-enable-2fa/ # Verify and enable 2FA
β β β βββ disable-2fa/route.ts # Disable 2FA
β β β βββ verify-2fa/route.ts # Verify 2FA token
β β βββ generator/route.ts # Password generation API
β β βββ vault/ # Vault CRUD operations
β β β βββ route.ts # GET (all items), POST (create)
β β β βββ [id]/route.ts # GET, PUT, DELETE by ID
β β β βββ count/route.ts # Get item count
β β β βββ verify-access/route.ts # Verify vault access
β β βββ TestAPI/ # Development test endpoints
β β βββ JwtTest/route.ts # Test JWT verification
β β βββ MongoTest/route.ts # Test MongoDB connection
β β
β βββ auth/ # Authentication pages
β β βββ signin/page.tsx # Login page with 2FA
β β βββ signup/page.tsx # Registration with optional 2FA
β β
β βββ components/ # Reusable components
β β βββ Header.tsx # Navigation with user menu
β β βββ TwoFactorEnableModal.tsx # 2FA setup modal
β β βββ TwoFactorDisableModal.tsx # 2FA disable modal
β β βββ VaultAccessModal.tsx # Vault password/2FA verification
β β
β βββ contexts/ # React Context providers
β β βββ UserContext.tsx # User authentication state
β β βββ VaultContext.tsx # Vault items & encryption key
β β βββ GeneratorContext.tsx # Generated password state
β β
β βββ dashboard/page.tsx # Dashboard with stats
β βββ generator/page.tsx # Password generator page
β βββ vault/page.tsx # Vault management page
β βββ profile/page.tsx # User profile & 2FA settings
β β
β βββ lib/ # Utility libraries
β β βββ mongodb.ts # MongoDB connection
β β βββ jwt.ts # JWT token generation/verification
β β βββ encryption.ts # AES-256 encryption/decryption
β β βββ passwordGenerator.ts # Password generation logic
β β βββ twoFactorAuth.ts # 2FA (TOTP) utilities
β β
β βββ models/ # MongoDB schemas
β β βββ user.ts # User model with 2FA support
β β βββ vaultItem.ts # Vault item model (encrypted)
β β
β βββ types/ # TypeScript types
β β βββ auth.ts # Authentication types
β β
β βββ layout.tsx # Root layout with providers
β βββ page.tsx # Landing page
β βββ globals.css # Global styles with CSS variables
β βββ favicon.ico # App favicon
β
βββ public/ # Static assets
β βββ file.svg
β βββ globe.svg
β βββ next.svg
β βββ vercel.svg
β βββ window.svg
β
βββ .env.local # Environment variables (not in repo)
βββ .env.example # Environment template
βββ .gitignore # Git ignore rules
βββ eslint.config.mjs # ESLint configuration
βββ next.config.ts # Next.js configuration
βββ package.json # Dependencies
βββ postcss.config.mjs # PostCSS configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
This application implements true zero-knowledge architecture using AES-256-CBC encryption via crypto-js.
| Feature | Description |
|---|---|
| Industry Standard | NSA-approved for classified information up to TOP SECRET |
| Symmetric Encryption | Same key encrypts and decrypts (fast, efficient) |
| 256-bit Key | 2^256 possible keys = computationally infeasible to brute force |
| Browser Compatible | Pure JavaScript implementation, no native crypto needed |
| Battle-Tested | Used by millions of applications worldwide |
- Lightweight: ~80KB minified, perfect for browser environments
- No Dependencies: Works without Node.js crypto module
- Wide Adoption: 8M+ weekly downloads on npm
- Regular Updates: Active maintenance and security patches
- PBKDF2 Support: Built-in key derivation (10,000 iterations)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER AUTHENTICATION β
β 1. User logs in β JWT token issued β
β 2. User navigates to Vault β Password/2FA verification β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ENCRYPTION KEY SETUP β
β 3. User provides encryption key (never sent to server) β
β 4. Key stored ONLY in React Context (memory) β
β 5. Key validated against existing encrypted data β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SAVING TO VAULT β
β 6. User enters password data in browser β
β 7. Client-side: AES.encrypt(data, key) β Base64 blob β
β 8. Send encrypted blob to server via HTTPS β
β 9. Server stores encrypted blob in MongoDB β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RETRIEVING FROM VAULT β
β 10. Server sends encrypted blobs to client β
β 11. Client-side: AES.decrypt(blob, key) β plaintext β
β 12. Display decrypted data in browser β
β 13. On logout: Clear encryption key from memory β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Server CAN See | Server CANNOT See |
|---|---|
| β User email (for login) | β User password (bcrypt hash only) |
| β Encrypted blobs (Base64) | β Plaintext passwords |
| β Tags (for filtering) | β Titles, usernames, URLs, notes |
| β Timestamps | β Encryption key (never transmitted) |
| β Item count | β Actual vault content |
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 15.5.4 | React framework with App Router |
| React | 18.3.1 | UI library |
| TypeScript | 5.7.2 | Type safety |
| Tailwind CSS | 4.0 | Utility-first styling |
| Framer Motion | 11.15.0 | Animations |
| Lucide React | 0.468.0 | Icon library |
| next-themes | 0.4.4 | Theme management |
| Technology | Version | Purpose |
|---|---|---|
| Next.js API Routes | 15.5.4 | RESTful API |
| MongoDB | Latest | NoSQL database |
| Mongoose | 8.9.4 | MongoDB ODM |
| JWT | 9.0.2 | Authentication tokens |
| bcryptjs | 2.4.3 | Password hashing |
| Technology | Version | Purpose |
|---|---|---|
| crypto-js | 4.2.0 | AES-256 encryption |
| Speakeasy | 2.0.0 | TOTP 2FA |
| qrcode | 1.5.4 | QR code generation |
Before you begin, ensure you have the following installed:
- Node.js: v18.0.0 or higher
- npm/yarn/pnpm: Latest version
- MongoDB: Local installation or MongoDB Atlas account
- Git: For cloning the repository
git clone https://github.com/Ananta2545/password-generator.git
cd password-generatornpm install
# or
yarn install
# or
pnpm installCreate a .env.local file in the root directory (or rename .env.example):
# MongoDB Connection String
MONGODB_URI=mongodb://localhost:27017/password-vault
# For MongoDB Atlas (recommended for production):
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/password-vault?retryWrites=true&w=majority
# JWT Secret Key (generate a strong random string)
# Generate using: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
JWT_SECRET=your-super-secret-jwt-key-min-32-characters-long
# Application URL (optional, defaults to localhost:3000)
NEXT_PUBLIC_APP_URL=http://localhost:3000MongoDB Atlas (Cloud)
- Create account at mongodb.com/cloud/atlas
- Create a free cluster
- Get connection string from "Connect" β "Connect your application"
- Add connection string to
.env.local
npm run dev
# or
yarn dev
# or
pnpm devNavigate to http://localhost:3000
-
Sign Up
- Navigate to
/auth/signup - Enter email and password (min 8 characters)
- Optionally enable 2FA during registration
- Scan QR code with authenticator app (Google Authenticator, Authy, etc.)
- Navigate to
-
Dashboard
- View total vault items
- Quick access to Generator and Vault
- See account statistics
-
Generate Strong Password
- Go to
/generator - Customize length (4-64 characters)
- Select character types (uppercase, lowercase, numbers, symbols)
- Click "Generate New" until satisfied
- Copy to clipboard (auto-clears after 15 seconds)
- Go to
-
Save to Vault
- Click "Save to Vault" button
- Verify identity with password (and 2FA if enabled)
- Enter encryption key (remember this!)
- Fill in item details (title, username, URL, notes)
- Add tags for organization
- Click "Save Item"
-
Manage Vault
- Search items by title, username, or tags
- Toggle password visibility with eye icon
- Copy passwords with auto-clear protection
- Edit items with pencil icon
- Delete items with custom confirmation modal
Choose your security level based on your needs:
Best for: Personal use, less sensitive data, quick access needs
Setup Steps:
- β Create account (email + password)
- β Start using vault immediately
- β Access requires: Password only
Vault Access Flow:
Click "Vault" β Enter Password β Enter Encryption Key β β
Access Granted
Security Level: π Medium
- Protected by account password
- Encrypted with your personal encryption key
- Faster access (1 verification step)
When to use:
- β You want quick access to your vault
- β You're the only one using your device
- β Your passwords are not highly sensitive
- β You prefer convenience over maximum security
Best for: Sensitive data, shared devices, maximum protection
Setup Steps:
- β Create account (email + password)
- β Go to Profile β Click "Enable Two-Factor Authentication"
- β Scan QR code with authenticator app (Google Authenticator, Authy, etc.)
- β Enter 6-digit code to confirm
- β 2FA is now active! π
Vault Access Flow:
Click "Vault" β Enter Password + 2FA Code β Enter Encryption Key β β
Access Granted
Security Level: ππ High
- Protected by account password + time-based code
- Even if password is stolen, attacker needs your phone
- Encrypted with your personal encryption key
- Industry-standard TOTP authentication
When to use:
- β You store highly sensitive passwords
- β You use shared or public computers
- β You want maximum protection
- β You have an authenticator app on your phone
Supported Authenticator Apps:
- Google Authenticator (iOS/Android)
- Microsoft Authenticator (iOS/Android)
- Authy (iOS/Android/Desktop)
- 1Password (iOS/Android/Desktop)
- Any TOTP-compatible app
| Feature | Without 2FA π | With 2FA ππ |
|---|---|---|
| Setup Time | Instant | 2 minutes |
| Vault Access | Password only | Password + 6-digit code |
| Access Speed | ~10 seconds | ~15 seconds |
| Protection | Password breach vulnerable | Protected even if password stolen |
| Best For | Quick access, personal use | Maximum security, sensitive data |
| Required | Account password | Account password + phone with authenticator |
Enable 2FA Later (Upgrade Security):
- Go to Profile page
- Click "Enable Two-Factor Authentication"
- Scan QR code with authenticator app
- Enter verification code
- β 2FA now protects your vault
Disable 2FA (Downgrade Security):
- Go to Profile page
- Click "Disable Two-Factor Authentication"
- Enter your password + current 2FA code
- β 2FA removed, back to password-only
π‘ Pro Tip: You can enable/disable 2FA anytime without losing your vault data!
- Go to Profile (
/profile) - Click "Enable Two-Factor Authentication"
- Scan QR code with authenticator app:
- Google Authenticator (iOS/Android)
- Authy (iOS/Android/Desktop)
- Microsoft Authenticator
- 1Password
- Enter 6-digit verification code
- β 2FA now active - required for vault access
- Go to Profile
- Click "Disable Two-Factor Authentication"
- Enter password and current 2FA code
- β 2FA removed from account
The vault has a two-layer security system: Identity Verification + Encryption Key.
Step 1: Navigate to Vault
ββββββββββββββββββββββββββββββββββββββββββββ
β User clicks "Vault" in navigation β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 2: Vault Access Verification Modal Appears
ββββββββββββββββββββββββββββββββββββββββββββ
β Modal Title: "Verify Your Identity" β
β β
β [Password Input Field] β
β β Enter your account password β
β β
β [Verify Access Button] β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 3: Password Verification
ββββββββββββββββββββββββββββββββββββββββββββ
β System checks: β
β β Password matches bcrypt hash β
β β User is authenticated β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 4: Encryption Key Prompt Appears
ββββββββββββββββββββββββββββββββββββββββββββ
β Modal Title: "Enter Encryption Key" β
β β
β "Your encryption key is required to β
β decrypt your vault items. This key β
β is never sent to the server." β
β β
β [Encryption Key Input Field] β
β β Enter the key you used when saving β
β β
β [Unlock Vault Button] β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 5: Key Validation (Client-Side)
ββββββββββββββββββββββββββββββββββββββββββββ
β System validates key by: β
β 1. Fetching encrypted items from server β
β 2. Attempting to decrypt first item β
β 3. If successful β Key is correct β β
β 4. If fails β "Invalid key" error β β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 6: Vault Unlocked! π
ββββββββββββββββββββββββββββββββββββββββββββ
β β All items decrypted client-side β
β β View, edit, delete, search enabled β
β β Encryption key stored in memory β
β β Key cleared when leaving vault β
ββββββββββββββββββββββββββββββββββββββββββββ
User Experience:
- Click "Vault" β Enter password β Enter encryption key β Access granted
- Total steps: 2 prompts (password, then encryption key)
- Time: ~10 seconds
Step 1: Navigate to Vault
ββββββββββββββββββββββββββββββββββββββββββββ
β User clicks "Vault" in navigation β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 2: Vault Access Verification Modal Appears (with 2FA)
ββββββββββββββββββββββββββββββββββββββββββββ
β Modal Title: "Verify Your Identity" β
β β
β [Password Input Field] β
β β Enter your account password β
β β
β [2FA Code Input Field] β
β β Enter 6-digit code from your β
β authenticator app (Google Auth, β
β Authy, etc.) β
β β
β β±οΈ Code expires every 30 seconds β
β β
β [Verify Access Button] β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 3: Password + 2FA Verification
ββββββββββββββββββββββββββββββββββββββββββββ
β System checks: β
β β Password matches bcrypt hash β
β β 2FA token is valid (TOTP) β
β β Token is within 30-sec window β
β β User is authenticated β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 4: Encryption Key Prompt Appears
ββββββββββββββββββββββββββββββββββββββββββββ
β Modal Title: "Enter Encryption Key" β
β β
β "Your encryption key is required to β
β decrypt your vault items. This key β
β is never sent to the server." β
β β
β [Encryption Key Input Field] β
β β Enter the key you used when saving β
β β
β [Unlock Vault Button] β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 5: Key Validation (Client-Side)
ββββββββββββββββββββββββββββββββββββββββββββ
β System validates key by: β
β 1. Fetching encrypted items from server β
β 2. Attempting to decrypt first item β
β 3. If successful β Key is correct β β
β 4. If fails β "Invalid key" error β β
ββββββββββββββββββββββββββββββββββββββββββββ
β
Step 6: Vault Unlocked! π
ββββββββββββββββββββββββββββββββββββββββββββ
β β All items decrypted client-side β
β β View, edit, delete, search enabled β
β β Encryption key stored in memory β
β β Key cleared when leaving vault β
ββββββββββββββββββββββββββββββββββββββββββββ
User Experience:
- Click "Vault" β Enter password + 2FA code β Enter encryption key β Access granted
- Total steps: 2 prompts (password+2FA, then encryption key)
- Time: ~15 seconds
- Click moon/sun icon in header
- Dark mode reduces eye strain
- Preference saved in browser
{
_id: ObjectId,
email: string, // Unique user email
password: string, // bcrypt hash (not plaintext)
twoFactorSecret?: string, // Encrypted TOTP secret (optional)
twoFactorEnabled: boolean, // 2FA status
createdAt: Date,
lastLogin?: Date
}{
_id: ObjectId,
userId: ObjectId, // Reference to User
encryptedData: string, // Base64 AES-256 encrypted blob containing:
// { title, username, password, url, notes }
tags: string[], // Searchable tags (not encrypted)
createdAt: Date,
lastModified: Date
}| Command | Description |
|---|---|
npm run dev |
Start development server (localhost:3000) |
npm run build |
Build production bundle |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm run type-check |
Run TypeScript compiler check |
# Run linter
npm run lint
# Type checking
npx tsc --noEmit
# Format code (if Prettier configured)
npx prettier --write .| Variable | Required | Description |
|---|---|---|
MONGODB_URI |
β Yes | MongoDB connection string |
JWT_SECRET |
β Yes | Secret key for JWT tokens (32+ chars) |
NEXT_PUBLIC_APP_URL |
β No | App URL (defaults to localhost:3000) |
Ananta Chatterjee
- π GitHub: @Anata2545
- π§ Email: chatterjeeanata091@gmail.com
- πΌ LinkedIn: Ananta Chattapadhyay
Madquick Digital Agency
- π’ Company: Web Development Company Top
- π Founder: Setu Agrawal
Built with β€οΈ by Ananta