Encryption at Rest vs in Transit: Complete Guide
Your data exists in two fundamental states: sitting on a disk somewhere, or moving between two points over a network. Each state exposes your data to different threats, and each requires a different encryption strategy. Understanding the distinction between encryption at rest and encryption in transit is not academic. It determines whether your sensitive data survives a server breach, a network interception, or a compromised cloud provider.
Two States of Data Vulnerability
Every piece of digital data cycles between two states. Data at rest is stored on a physical medium: a hard drive, an SSD, a database server, a USB drive, a cloud storage bucket. Data in transit is actively moving: traveling over the internet, crossing a local network, being transmitted between services via an API call, or streaming from a server to your browser.
There is also a third state, data in use, which refers to data actively being processed in memory. This state is increasingly important and is addressed by technologies like Intel SGX and AMD SEV, but the primary security conversation still revolves around rest and transit because these are the states where most breaches occur.
Each state faces distinct attack vectors:
- Data at rest is vulnerable to physical theft (stolen laptops, removed drives), unauthorized database access (SQL injection, compromised credentials), insider threats (employees or contractors with direct storage access), and legal compulsion (subpoenas, government orders to produce stored data).
- Data in transit is vulnerable to network interception (man-in-the-middle attacks), packet sniffing on unsecured networks (public Wi-Fi), DNS hijacking that redirects traffic through attacker-controlled servers, and compromised network infrastructure (the 2024 Salt Typhoon telecom attacks demonstrated this at scale).
Encrypting only one state leaves the other exposed. A database encrypted at rest is meaningless if the data travels to the application server in plaintext over an unencrypted connection. Similarly, TLS protects data beautifully during transmission, but once it arrives at the server and is written to disk unencrypted, a database breach exposes everything.
What Is Encryption at Rest
Encryption at rest protects stored data by converting it into ciphertext using an encryption algorithm and a key. The data remains encrypted on disk and is only decrypted when an authorized application or user needs to read it. If an attacker gains access to the physical storage medium or the raw database files, they obtain only unintelligible ciphertext.
There are several layers at which encryption at rest can be applied:
Full Disk Encryption (FDE)
Full disk encryption protects the entire storage volume. Every sector on the disk is encrypted, including the operating system, application files, temporary files, and swap space. BitLocker (Windows), FileVault (macOS), and LUKS (Linux) are the standard implementations. FDE protects against physical theft of the device. If someone steals your laptop, they cannot read the drive without the decryption key, which is typically unlocked by your login password or a TPM chip.
The limitation of FDE is that it protects only against offline attacks. Once the system is booted and the disk is unlocked, all data is accessible to any process running with sufficient privileges. FDE does nothing to protect against a remote attacker who compromises a running system.
Database-Level Encryption
Database systems like PostgreSQL, MySQL, and MongoDB offer Transparent Data Encryption (TDE), which encrypts the database files on disk. The database engine handles encryption and decryption transparently, so applications do not need to change their queries. AWS RDS, Azure SQL, and Google Cloud SQL all offer TDE as a built-in feature.
TDE protects against someone who gains access to the raw database files (through a storage-level breach or a backup that falls into the wrong hands) but does not protect against someone who gains access to the running database through compromised credentials or SQL injection. From the database engine's perspective, an authenticated query from a legitimate user and an authenticated query from an attacker using stolen credentials are indistinguishable.
Application-Level Encryption
The strongest form of encryption at rest happens at the application level, before data reaches the database. The application encrypts sensitive fields (Social Security numbers, credit card numbers, API keys) using a key that only the application controls. The database stores ciphertext. Even a full database compromise yields only encrypted values that the attacker cannot decrypt without the application's encryption key.
This is the approach used by AES-256 encryption in security-focused applications. When you encrypt text using SecureBin's text encryption tool, the encryption happens in your browser before any data is transmitted. The server stores only ciphertext and never possesses the key.
What Is Encryption in Transit
Encryption in transit protects data while it moves between two endpoints. The data is encrypted before transmission and decrypted upon arrival. Anyone who intercepts the data stream between sender and receiver obtains only encrypted packets that are computationally infeasible to decrypt.
The dominant protocol for encryption in transit is TLS (Transport Layer Security), the successor to SSL. When you see HTTPS in your browser's address bar, TLS is encrypting the connection between your browser and the web server. But TLS is far more than just HTTPS:
- HTTPS (TLS over HTTP): Encrypts web traffic between browsers and servers. Modern browsers mark HTTP sites as "Not Secure" to push universal HTTPS adoption.
- SMTPS / STARTTLS: Encrypts email in transit between mail servers. Without it, email traverses the internet in plaintext, readable by any network device it passes through.
- TLS for databases: Encrypts the connection between an application server and a database. Without this, SQL queries and their results (which may contain passwords, personal data, or financial records) travel in plaintext across the network.
- mTLS (mutual TLS): Both the client and server present certificates and verify each other's identity. Used extensively in microservice architectures (service mesh implementations like Istio enforce mTLS between all services) and zero trust networks.
- VPN tunnels (IPsec, WireGuard): Encrypt all traffic between two network endpoints, creating an encrypted tunnel through which all data flows.
How TLS Works
A TLS connection begins with a handshake. The client and server agree on a cipher suite, the server presents its certificate (which the client verifies against trusted certificate authorities), and they perform a key exchange (typically using ECDHE, Elliptic Curve Diffie-Hellman Ephemeral) to derive a shared session key. All subsequent data is encrypted with this session key using a symmetric cipher like AES-256-GCM.
The critical property of the ECDHE key exchange is forward secrecy. Even if the server's private key is later compromised, past session keys cannot be derived from it. Each session uses a unique ephemeral key that is discarded after the session ends. This means an attacker who records encrypted traffic today and obtains the server's private key next year still cannot decrypt the recorded traffic.
AES vs TLS: Which Does What
AES and TLS are not competing technologies. They operate at different layers and frequently work together. Understanding the distinction is essential.
AES (Advanced Encryption Standard) is a symmetric encryption algorithm. It takes plaintext and a key as input and produces ciphertext. AES operates on data. It does not know or care about networks, connections, or protocols. AES-256 uses a 256-bit key, providing 2^256 possible key combinations. It is used for encryption at rest (encrypting files on disk, encrypting database fields) and is also used inside TLS as the symmetric cipher for encrypting the data stream after the handshake completes.
TLS (Transport Layer Security) is a protocol. It handles authentication (verifying the server is who it claims to be), key exchange (securely establishing a shared secret over an insecure channel), and then uses a symmetric cipher (typically AES-256-GCM) to encrypt the data flowing through the connection. TLS is about securing the connection. AES is about securing the data.
In practice, when data is encrypted in transit via HTTPS, the data is being encrypted with AES inside a TLS connection. TLS negotiated the keys; AES performs the actual encryption. When data is encrypted at rest using application-level encryption, AES performs the encryption directly, without TLS involvement.
Think of TLS as a secure courier service and AES as a locked safe. TLS ensures the courier cannot be intercepted or impersonated during delivery. AES ensures that even if the courier is compromised, the contents of the safe remain unreadable. The highest security uses both: a locked safe delivered by a secure courier.
When You Need Both Types
The short answer is always. Any system handling sensitive data requires both encryption at rest and encryption in transit. Here is why each alone is insufficient:
Encryption in Transit Only
Imagine a healthcare application that uses HTTPS for all connections but stores patient records in an unencrypted database. The data is protected while traveling between the patient's browser and the server. But the database server's hard drive contains plaintext patient records. A single database breach, a stolen backup tape, a misconfigured S3 bucket containing database dumps, or an insider with database access exposes every record.
This is not hypothetical. The 2019 Capital One breach exposed 106 million customer records stored in unencrypted S3 buckets. The data was encrypted in transit (HTTPS), but stored in plaintext. A single SSRF vulnerability gave the attacker access to everything.
Encryption at Rest Only
Consider a financial application that encrypts its database with TDE but connects to the database over an unencrypted network connection. The data on disk is protected, but every SQL query and result set travels across the network in plaintext. An attacker with access to the network (through a compromised switch, a rogue access point, or a position in the data center network) can read every transaction, every account balance, and every customer record as it flows between the application and database.
In cloud environments, where multiple tenants share physical network infrastructure, unencrypted internal traffic is particularly dangerous. AWS, Azure, and Google Cloud all recommend encrypting internal traffic even within a VPC, because the shared physical infrastructure means your traffic may traverse hardware used by other tenants.
The Defense-in-Depth Argument
Using both encryption at rest and in transit is a textbook example of defense in depth. If TLS is somehow bypassed (a misconfigured proxy that terminates TLS and forwards plaintext, a compromised certificate authority, a protocol downgrade attack), encryption at rest still protects the stored data. If encryption at rest is bypassed (compromised key management, a vulnerability in the database engine), TLS still protects the data while it moves across the network.
Encrypt Your Data End-to-End
SecureBin uses AES-256-GCM encryption in your browser before data ever reaches the network. Your data is encrypted at rest on our servers and in transit via TLS. We never have the decryption key.
Try Text EncryptionZero-Knowledge Encryption: The Third Layer
Encryption at rest and in transit are necessary but not sufficient for true data security. Both have a fundamental limitation: someone other than you holds the decryption key.
With standard encryption at rest, the service provider generates and manages the encryption key. AWS manages the KMS key for your encrypted RDS database. Google manages the key for your encrypted Cloud Storage bucket. The provider can decrypt your data if compelled by law enforcement, if an employee goes rogue, or if their key management infrastructure is compromised.
With standard encryption in transit, TLS protects the data between endpoints, but the data is decrypted at each endpoint. The service provider receives your data in plaintext after TLS termination. Every HTTPS request you send to a web application is decrypted by the application server, which then processes it in plaintext.
Zero-knowledge encryption eliminates this gap. In a zero-knowledge architecture:
- Encryption and decryption happen exclusively on the client device (your browser or application)
- The encryption key is derived from a password or passphrase that only you know, or is generated client-side and communicated out-of-band
- The service provider stores only ciphertext and never possesses the decryption key
- Even with full access to their own servers, databases, and infrastructure, the provider cannot decrypt your data
- A breach of the provider's systems exposes only encrypted ciphertext that is computationally infeasible to decrypt
Zero-knowledge encryption makes the trustworthiness of the service provider irrelevant to the security of your data. You do not need to trust that the provider will not read your data, because the provider is architecturally incapable of reading it. This is the model SecureBin uses: your data is encrypted in your browser with AES-256-GCM before it ever reaches our servers, and the encryption key is embedded in the URL fragment, which is never sent to the server.
Implementation Guide for Developers
If you are building an application that handles sensitive data, here is a practical guide to implementing both types of encryption correctly.
Encryption in Transit
- Enforce TLS 1.2 or higher everywhere. Disable TLS 1.0 and 1.1, which have known vulnerabilities. Configure your web server and load balancer to reject connections using outdated protocols.
- Use strong cipher suites. Prefer AES-256-GCM with ECDHE key exchange. Disable CBC-mode ciphers (vulnerable to padding oracle attacks) and RSA key exchange (no forward secrecy).
- Enable HSTS. HTTP Strict Transport Security tells browsers to always use HTTPS for your domain, preventing protocol downgrade attacks. Set
Strict-Transport-Security: max-age=31536000; includeSubDomains. - Encrypt internal connections. Do not assume internal network traffic is safe. Use TLS for database connections, inter-service communication, and cache server connections (Redis, Memcached). In Kubernetes, deploy a service mesh like Istio that enforces mTLS between all pods.
- Certificate management. Use automated certificate management (Let's Encrypt with certbot, or AWS ACM) to prevent certificate expiration. Pin certificates or use Certificate Transparency monitoring to detect unauthorized certificate issuance.
Encryption at Rest
- Enable storage-level encryption. Turn on EBS encryption (AWS), managed disk encryption (Azure), or persistent disk encryption (GCP) for all volumes. This is the baseline.
- Enable database encryption. Use TDE for your database engine. For AWS RDS, encryption is a one-click setting at database creation time (it cannot be enabled after creation without creating an encrypted snapshot and restoring from it).
- Implement application-level encryption for sensitive fields. Do not rely solely on storage and database encryption. Encrypt PII, credentials, and other sensitive data at the application level before writing to the database. Use a library like
libsodiumor the Web Crypto API for client-side encryption. - Manage keys properly. Never store encryption keys alongside the data they protect. Use a dedicated key management service (AWS KMS, HashiCorp Vault, Azure Key Vault). Implement key rotation policies. Use envelope encryption where a data encryption key (DEK) encrypts the data, and a key encryption key (KEK) in KMS encrypts the DEK.
- Encrypt backups. Database backups, log archives, and data exports must be encrypted. An unencrypted backup of an encrypted database completely negates the encryption.
Zero-Knowledge Layer
For the highest security posture, add client-side encryption on top of your transit and at-rest encryption:
// Browser-side encryption using Web Crypto API
const key = await crypto.subtle.generateKey(
{ name: 'AES-GCM', length: 256 },
true,
['encrypt', 'decrypt']
);
const iv = crypto.getRandomValues(new Uint8Array(12));
const encoded = new TextEncoder().encode(sensitiveData);
const ciphertext = await crypto.subtle.encrypt(
{ name: 'AES-GCM', iv },
key,
encoded
);
// Send only ciphertext to server
// Key stays in browser, shared via URL fragment
Frequently Asked Questions
What is the difference between encryption at rest and in transit?
Encryption at rest protects data stored on disk, in databases, or in cloud storage. Encryption in transit protects data while it moves across a network. At rest uses algorithms like AES-256 applied to stored files or database fields. In transit uses protocols like TLS to secure network connections. Both protect against different attack vectors: at rest guards against storage breaches and physical theft; in transit guards against network interception and man-in-the-middle attacks. A comprehensive security strategy requires both.
Is TLS the same as encryption in transit?
TLS is the most widely used protocol for encryption in transit, but it is not the only one. VPN protocols (IPsec, WireGuard), SSH tunnels, and application-specific encryption protocols also provide encryption in transit. However, TLS is the standard for web traffic (HTTPS), email (SMTPS), database connections, and API communication. When people say "encryption in transit," they almost always mean TLS or a protocol built on top of TLS.
Can data be encrypted both at rest and in transit?
Yes, and it should be. These are complementary protections, not alternatives. Data encrypted in transit via TLS is decrypted when it arrives at the server, then re-encrypted at rest when written to storage. With zero-knowledge encryption, data can remain encrypted across both states: the client encrypts before transmission, the ciphertext travels through a TLS-encrypted connection, and the ciphertext is stored encrypted on the server. At no point does the server see plaintext. This is the architecture SecureBin uses.
Related Articles
Continue reading: What Is AES-256 Encryption, What Is Zero-Knowledge Encryption, Zero Trust Credential Sharing, Best Secret Sharing Tools 2026.
Usman has 10+ years of experience securing enterprise infrastructure, managing high-traffic servers, and building zero-knowledge security tools. Read more about the author.