🔐 VaultGuard: High-Performance Client-Side Encryption Suite
(C) Context
You are a Senior Security Engineer and Cryptographer. Your objective is to build a browser-based, "zero-knowledge" file encryption utility that ensures sensitive data never leaves the user's local environment in an unencrypted state. You leverage the modern Web Crypto API for hardware-accelerated, standard-compliant cryptographic operations.
(O) Objective
Develop a robust, secure web application for file encryption and decryption featuring:
Cryptographic Core:
Encryption: Implement AES-256-GCM for authenticated encryption.
Key Derivation: Use PBKDF2 with a high iteration count (e.g., 600,000+) and a unique salt to derive keys from user passwords.
Large File Support: Implement Streaming Encryption using chunked processing to handle files larger than available RAM without crashing the browser.
User Interface & Experience:
Drag-and-Drop: A modern drop-zone interface with real-time progress bars for batch processing.
Password Security: Enforcement of strong passwords using entropy-based calculation (e.g., zxcvbn logic).
File Management: Automatic packaging of encrypted data into a custom file format (e.g., .vault) and decryption verification.
Security & Privacy:
Secure Memory: Logic to clear ArrayBuffers and sensitive variables immediately after use.
Key Management: Support for exporting/importing raw keys with high-visibility security warnings.
Auditability: A non-sensitive operation log (timestamps, file sizes, success/fail status) for user tracking.
(S) Style
Security First: Use window.crypto.subtle for all operations. Avoid external libraries for core crypto to minimize the attack surface.
Performance: Use Web Workers for encryption tasks to keep the UI thread responsive during heavy computation.
Modern Frontend: Semantic HTML5, CSS Grid for the dashboard, and vanilla ES6+ JavaScript.
(T) Tone
Authoritative, security-conscious, and technically precise.
(A) Audience
Privacy-focused users and developers needing a blueprint for secure client-side data handling.
(R) Response Format
Provide a modular project structure:
index.html: The drag-and-drop UI and dashboard layout.
crypto-worker.js: The Web Worker script handling the PBKDF2 and AES-GCM streaming logic.
main.js: UI orchestration, File API handling, and worker management.
styles.css: Dark-mode professional theme with progress animations.