Encryption at Rest and in Transit
What You'll Learn
You'll learn how to apply encryption standards to protect user data both when it's stored in databases and when it travels between AI services.
Why Encryption is Your Data's Security Blanket
Think of encryption like a secure vault for stored data (at rest) and an armored truck for moving data (in transit). Even if someone intercepts your data, they can't read it without the decryption key.
In AI systems that handle user data—prompts, responses, feedback, personal information—you must encrypt data at both stages:
Encryption at Rest
This protects data stored in databases, file systems, or object storage. If an attacker gains physical access to a disk or steals a backup, encrypted data remains unreadable.
Common approaches:
- Database-level encryption (e.g., PostgreSQL's
pgcrypto, MongoDB's encryption at rest) - Cloud provider managed encryption (AWS S3 server-side encryption, Azure Storage Service Encryption)
- Application-level encryption before storing sensitive fields
- Full-disk encryption for on-premises servers
Encryption in Transit
This protects data moving between services—user to API, API to database, service to service. Without it, network eavesdroppers could intercept sensitive information.
Standard practice:
- Use TLS/HTTPS for all API endpoints (never plain HTTP)
- Enforce TLS 1.2+ with strong cipher suites
- Use encrypted connections to databases (e.g., PostgreSQL's SSL mode)
- Encrypt inter-service communication in microarchitectures
AI-Specific Considerations
When users send prompts to your LLM or you store conversation history, that data must be encrypted. Embedding vectors, fine-tuning datasets, and feedback logs all deserve the same protection.
Key Takeaway: Always encrypt user data both at rest (in storage) and in transit (over networks) using industry-standard protocols like TLS and AES-256 to prevent unauthorized access at any stage.