π LexCrypt β Full-Stack Cryptography Vault
Military-grade AES-256 encryption, RSA key pairs, SHA-256 digital signatures β built with React.js + Node.js + Express + MongoDB.
π AES-256 Encryption β Secure sensitive data
βοΈ RSA-2048 Digital Signatures β Identity verification
π§Ύ SHA-256 Hashing β Tamper detection
π Secure file upload & vault system
π Authentication system (Login / Signup)
Layer
Technology
Frontend
React 18, React Router v6, Axios, Framer Motion, react-hot-toast
Backend
Node.js, Express.js
Database
MongoDB + Mongoose ODM
Auth
JWT (jsonwebtoken) + bcryptjs
Encryption (server)
Node.js crypto β AES-256-CBC, PBKDF2-SHA256
Encryption (client)
Web Crypto API β AES-CBC, PBKDF2, SHA-256
Security
Helmet.js, CORS, express-rate-limit, express-validator
lexcrypt/
βββ backend/ β Node.js + Express + MongoDB API
β βββ src/
β β βββ server.js β Entry point
β β βββ app.js β Express app (CORS, Helmet, rate limiting)
β β βββ config/
β β β βββ db.js β Mongoose connection
β β βββ models/
β β β βββ user.model.js β User schema (bcrypt password hashing)
β β β βββ vaultFile.model.js β Encrypted file records
β β β βββ signature.model.js β Digital signature records
β β βββ middleware/
β β β βββ auth.middleware.js β JWT Bearer token verification
β β βββ controllers/
β β β βββ auth.controller.js β Signup, login, getMe, saveKeys
β β β βββ vault.controller.js β Upload, list, decrypt, delete
β β β βββ crypto.controller.js β Text encrypt/decrypt
β β β βββ signature.controller.js β Sign, verify, list, delete
β β βββ routes/
β β β βββ auth.routes.js
β β β βββ vault.routes.js
β β β βββ crypto.routes.js
β β β βββ signature.routes.js
β β βββ utils/
β β βββ crypto.utils.js β AES-256-CBC, PBKDF2, SHA-256, signatures
β β βββ jwt.utils.js β Token signing + response helper
β βββ uploads/ β Static file storage
β βββ .env.example
β βββ package.json
β
βββ frontend/ β React.js SPA
βββ public/
β βββ index.html
βββ src/
β βββ index.js β ReactDOM entry
β βββ App.jsx β Router + AuthProvider + Toaster
β βββ api/
β β βββ index.js β Axios instance + JWT interceptor + all API calls
β βββ context/
β β βββ AuthContext.jsx β Global auth state (useReducer)
β βββ utils/
β β βββ crypto.js β Client-side AES-256-CBC, SHA-256, key generation
β βββ components/
β β βββ ui/index.jsx β Button, Input, Card, Badge, Alert, Spinnerβ¦
β β βββ layout/index.jsx β MatrixCanvas, Navbar, ProtectedRoute
β βββ pages/
β β βββ Landing.jsx
β β βββ Signup.jsx
β β βββ Login.jsx
β β βββ Vault.jsx β 4-step key wizard
β β βββ Upload.jsx β File encrypt/vault/decrypt with modal auth
β β βββ Crypto.jsx β Text encrypt/decrypt via API
β β βββ Signatures.jsx β Sign, verify, log via API
β βββ styles/
β βββ globals.css
βββ .env
βββ package.json
π Security Architecture
Layer
What's protected
How
Transport
All API calls
HTTPS (production) + CORS whitelist
Authentication
Every protected route
JWT Bearer tokens (7-day expiry)
Passwords
User passwords in DB
bcrypt (12 rounds)
Rate Limiting
All routes
200 req/15min global; 20 req/15min auth
Headers
XSS, clickjacking etc.
Helmet.js
File Encryption
Files in MongoDB
AES-256-CBC, PBKDF2-SHA256, random IV per file
Integrity
Every vault file
SHA-256 hash stored at encrypt time, verified at decrypt time
Authentication
File decryption
Private key required, normalised comparison
Non-repudiation
Vault files
SHA-256(hash:userId:fileId) digital signature
Private keys
User's private key
Never sent to server β session-only (sessionStorage)
π Setup & Installation
Node.js β₯ 18
MongoDB (local or MongoDB Atlas)
npm or yarn
cd lexcrypt/backend
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env:
# MONGO_URI=mongodb://localhost:27017/lexcrypt
# JWT_SECRET=your_minimum_32_char_secret_here
# PORT=5000
# Start development server
npm run dev
# β LexCrypt Backend running on port 5000
# β MongoDB: connected
cd lexcrypt/frontend
# Install dependencies
npm install
# Start React development server
npm start
# β Opens http://localhost:3000
3. MongoDB Atlas (Production)
Replace MONGO_URI in .env with your Atlas connection string:
MONGO_URI=mongodb+srv://<user>:<password>@cluster0.xxxxx.mongodb.net/lexcrypt?retryWrites=true&w=majority
User uploads file
β FileReader reads bytes as base64
β SHA-256(base64) computed client-side β stored as integrity hash
β AES secret = PBKDF2-SHA256(publicKey, salt, 100000 iterations)
β AES-256-CBC encrypts base64 with random IV
β { cipherText, iv, sha256Hash } sent to backend API (JWT auth)
β Backend generates digital signature: SHA-256(hash:userId:fileId)
β All stored in MongoDB VaultFile document
User clicks Decrypt
β Private key modal opens, shows SHA-256 fingerprint + digital signature
β User enters private key
β Frontend: normaliseKey(input) === normaliseKey(sessionPrivKey) β auth check
β POST /api/vault/decrypt/:id { privateKey }
β Backend: verifySignature(hash, userId, fileId, storedSig) β sig check
β Backend: AES-256-CBC decrypt with stored keySecret
β Backend: SHA-256(decrypted) === storedHash β integrity check
β { decryptedContent, sigValid, integrityOk } returned
β Client reconstructs file bytes, shows preview + download
Text Encryption (Crypto page)
POST /api/crypto/encrypt { plainText, publicKey }
β Server: secret = SHA-256(publicKey)
β Server: { cipherText, iv } = AES-256-CBC(plainText, PBKDF2(secret))
β Server stores keySecret on user document
β Returns { cipherText, iv, sha256, algorithm }
POST /api/crypto/decrypt { cipherText, iv, privateKey }
β Server retrieves keySecret from user.keySecret
β Server: AES-256-CBC decrypt
β Returns { plainText }
Method
Endpoint
Auth
Body
Description
POST
/signup
β
{ firstName, lastName, username, email, password }
Register new user
POST
/login
β
{ identifier, password }
Login, returns JWT
GET
/me
β
JWT
β
Get current user
PUT
/keys
β
JWT
{ publicKey, keySecret, vaultName }
Save vault keys
Method
Endpoint
Auth
Body
Description
POST
/upload
β
JWT
{ originalName, mimeType, size, cipherText, iv, sha256Hash, publicKey }
Upload encrypted file
GET
/files
β
JWT
β
List all vault files (no cipherText)
POST
/decrypt/:id
β
JWT
{ privateKey }
Decrypt a vault file
DELETE
/files/:id
β
JWT
β
Delete vault file
Method
Endpoint
Auth
Body
Description
POST
/encrypt
β
JWT
{ plainText, publicKey }
AES-256 encrypt text
POST
/decrypt
β
JWT
{ cipherText, iv, privateKey }
AES-256 decrypt text
Signatures β /api/signatures
Method
Endpoint
Auth
Body
Description
POST
/sign
β
JWT
{ content, label }
SHA-256 sign document
POST
/verify
β
JWT
{ content, hash }
Verify SHA-256 hash
GET
/
β
JWT
β
List all signatures
DELETE
/:id
β
JWT
β
Delete signature
Private keys are never sent to the server. They live only in sessionStorage during the browser session. Once you close the tab, they're gone β save them!
The AES key is derived from SHA-256(publicKey) via PBKDF2 with 100,000 iterations and a fixed salt. Both frontend and backend use the same derivation so they always produce the same AES key.
Each file gets a unique random IV for AES-CBC β even encrypting the same file twice produces different ciphertext.