Data Encryption
Transforming data into an unreadable format using cryptographic algorithms. Encryption at rest protects stored data; encryption in transit protects data over the network.
What is Data Encryption?
In short
Data encryption is the process of converting readable data (plaintext) into an unreadable form (ciphertext) using a cryptographic algorithm and a key, so that only someone holding the correct key can turn it back. Systems encrypt data at rest (on disk) to protect stored data and data in transit (over the network, usually with TLS) to protect it as it moves between machines.
What it actually is
Encryption takes plaintext and a secret key, runs them through a math function, and produces ciphertext that looks like random noise. Decryption reverses it using a key. Without the right key, the ciphertext is useless. The strength of the scheme comes from the key staying secret and the algorithm being hard to reverse, not from hiding how the algorithm works.
There are two families. Symmetric encryption uses the same key to encrypt and decrypt; AES-256 is the standard here and it is fast enough to encrypt gigabytes per second on modern CPUs that have AES-NI hardware instructions. Asymmetric encryption uses a key pair, a public key to encrypt and a private key to decrypt; RSA-2048 and elliptic-curve schemes like Curve25519 are common. Asymmetric is slow, so real systems use it only to exchange a small symmetric key, then switch to symmetric for the bulk data. That hybrid pattern is exactly what TLS does on every HTTPS connection.
At rest versus in transit
Encryption at rest protects data sitting on disk, in a database, or in object storage, so that a stolen drive or a leaked backup file is unreadable. This is often transparent. AWS RDS, EBS volumes, and S3 buckets can encrypt every block with AES-256 with one setting, and the application never sees a difference. The database still decrypts on read, so encryption at rest does not protect against an attacker who already has valid database credentials; it protects against theft of the underlying media.
Encryption in transit protects data while it moves across a network so nobody can read or tamper with it on the wire. TLS 1.3 is the workhorse: it does a handshake to agree on a session key, then encrypts the rest of the connection. The same idea covers service-to-service traffic inside a cluster (mTLS between microservices) and replication traffic between database nodes.
A third category, encryption in use, keeps data encrypted even while being processed, using techniques like homomorphic encryption or hardware enclaves such as Intel SGX. It is far slower and still niche, used mostly for highly sensitive multi-party computation.
Trade-offs and the hard part: keys
Encryption is cheap; key management is the real work. If you lose the key, the data is gone forever. If the key leaks, the encryption bought you nothing. This is why teams use a Key Management Service such as AWS KMS, Google Cloud KMS, or HashiCorp Vault, which store master keys in hardware security modules and hand out short-lived data keys. A common pattern is envelope encryption: a data key encrypts the data, and a master key in the KMS encrypts the data key, so the plaintext master key never leaves the HSM.
The costs are modest but real. Symmetric encryption adds a few percent CPU overhead; the TLS handshake adds one network round trip on a new connection, which is why connection reuse and session resumption matter. Encrypted data also does not compress well and you usually cannot run a database index over an encrypted column, so field-level encryption forces awkward choices about what stays searchable.
Rotate keys on a schedule, never hard-code keys in source or config files, and prefer authenticated modes like AES-GCM that detect tampering rather than older modes like AES-CBC used alone.
A concrete example
When you open https://www.systemdesign.academy, your browser and the server run a TLS 1.3 handshake. They use asymmetric crypto (an ECDHE key exchange) to agree on a shared symmetric session key without ever sending it across the wire, verify the server certificate against a trusted certificate authority, then encrypt every byte of the page and your form submissions with AES-GCM under that session key. An attacker sniffing the WiFi sees only ciphertext.
Behind the scenes, the user records that page writes land in a Postgres database on an encrypted EBS volume, and nightly backups go to an S3 bucket with server-side AES-256 encryption whose keys are managed by KMS. So the same data is protected in transit by TLS, then at rest by disk and storage encryption, two independent layers covering two different threats.
Where it is used in production
AWS KMS and S3
S3 and RDS encrypt data at rest with AES-256, while KMS manages master keys in HSMs and powers envelope encryption for application data.
Cloudflare
Terminates and re-encrypts TLS for millions of sites, offering free certificates and TLS 1.3 by default to encrypt traffic in transit.
Signal
Uses end-to-end encryption so message ciphertext can only be read on the sender and recipient devices, not by Signal servers.
PostgreSQL
Supports TLS for client and replication connections plus pgcrypto for column-level field encryption inside the database.
Frequently asked questions
- What is the difference between encryption and hashing?
- Encryption is reversible: with the key you can recover the original data, which is what you want for messages and stored files. Hashing is one-way and has no key to reverse it, so it is used for things you only need to verify, like passwords, where you compare hashes instead of storing the secret.
- Does encryption at rest protect me if my app gets hacked?
- Usually not. Encryption at rest stops someone who steals the physical disk or a raw backup file. If an attacker has valid database or application credentials, the system decrypts data for them just like it does for a legitimate request. You need access controls and field-level encryption for that threat.
- Is AES-256 better than AES-128?
- AES-256 has a larger key and a wider safety margin, including against future quantum attacks, but AES-128 is still considered unbreakable in practice and is slightly faster. Most teams pick AES-256 for sensitive data because the extra cost is tiny, but AES-128 is not weak.
- What is end-to-end encryption?
- End-to-end encryption means data is encrypted on the sender's device and only decrypted on the recipient's device, so servers in between, including the service provider, only ever see ciphertext. Signal and WhatsApp messaging work this way, unlike normal TLS where the server can read the data after decrypting it.
- Why does losing the encryption key mean losing the data?
- Strong encryption is designed so that ciphertext is computationally infeasible to reverse without the key. There is no backdoor or recovery, so if the only copy of the key is gone, the data is permanently unrecoverable. That is why key backup and rotation through a KMS is treated as critical.
Learn Data Encryption hands-on
This page explains the idea. The full lesson lets you step through the ring as servers join and leave, read the implementation, and check yourself with a quiz. It is one of 760+ lessons in the System Design Masterclass, from your first API call to distributed consensus. Eleven Foundation lessons are free, no signup. Lifetime access is ₹499 in India or $7.99 worldwide, one payment, no subscription.
See also
Related glossary terms you might want to look up next.
SSL/TLS
Cryptographic protocols that encrypt data in transit between client and server. TLS is the modern successor to SSL. The 'S' in HTTPS.
PII
Personally Identifiable Information: any data that can identify a specific individual, like name, email, SSN, or IP address. Must be encrypted and access-controlled.
GDPR
General Data Protection Regulation: EU law governing how personal data is collected, stored, and processed. Requires consent, data portability, and the right to be forgotten.
Data Lineage
Tracking data from its origin through every transformation and system it passes through. Answers 'where did this number come from?' for audits and debugging.
Data Catalog
A searchable inventory of all datasets in an organization, with metadata like schema, owner, freshness, and lineage. The 'Google for your data.'
Data Masking
Replacing sensitive data with realistic but fake values so developers and testers can work with production-like data without exposing real PII.