
Encrypted database layer API
Why Choose This Project
In many web and mobile applications, sensitive data (e.g., user details, financial info, medical records) is stored in plaintext within the database, which creates major security risks. This project focuses on building an API layer that encrypts/decrypts data before it is stored or retrieved, ensuring that data is unreadable even if the database is compromised.
This is an ideal project to learn about data-at-rest encryption, crypto libraries, secure key handling, and zero-trust storage models.
What You Get in This Project
A secure RESTful API that interfaces with a backend database, automatically encrypting and decrypting sensitive fields (like emails, passwords, addresses, etc.) before any data leaves or enters the database.
Technology Stack
Layer | Technologies Used |
---|---|
Backend API | Node.js (Express) / Spring Boot / Django REST |
Encryption Lib | Crypto (Node.js), PyCrypto / Fernet (Python), BouncyCastle (Java) |
Database | PostgreSQL / MySQL / MongoDB |
Key Storage | Environment Variables, AWS KMS / Vault (optional) |
Auth | JWT or OAuth2 for access control |
API Format | REST / GraphQL |
How It Works
-
API Request
Client sends a normal API request with plaintext data (e.g., user info). -
Encryption Before Insert
The API encrypts sensitive fields using AES-256 / RSA before saving to the database. -
Decryption After Fetch
When data is fetched from the database, encrypted fields are decrypted at the API level before returning to the client. -
Key Management
Uses securely stored symmetric keys or asymmetric key pairs. (Advanced: Integrate with AWS KMS or HashiCorp Vault.) -
Field-Level Encryption
Only selected fields (like email, phone, salary) are encrypted—others stay in plaintext for indexing or filtering.
Key Features
Feature | Description |
---|---|
AES-256 or RSA Encryption | Encrypt data at rest before database storage |
Field-Level Encryption | Only specified fields (e.g., ssn , email ) are encrypted |
Decryption on Read | Automatically decrypts fields when accessed via API |
Key Rotation Support | Allow regeneration and re-encryption with new keys |
Key Protection | Secure key management using .env, KMS, or Vault |
Audit Logging (Optional) | Logs all encryption/decryption events for security auditing |
Swagger/OpenAPI Support | API documented using Swagger or Postman |
Encryption Testing | Tools to test encryption/decryption, fuzz inputs, and simulate breaches |