A copy of the dealer portal database lands in the wrong storage bucket, a backup drive goes missing, or an employee can see more than a query screen should show. If the data is not encrypted, each of these is a data breach on the spot. If it is encrypted and the key sits somewhere separate and safe, what was stolen is an unreadable heap of bytes. Data encryption means making business data unreadable both while it travels and while it is stored; key management is the part that carries most of the weight, because encryption is rarely broken, while keys get lost or leaked.
In this guide we cover symmetric and asymmetric encryption, encryption in transit and at rest, field-level encryption, how it differs from password hashing, envelope encryption, key rotation, the performance impact, the search problem it creates, encrypting backups, and the cost–loss calculation. All example figures are representative; they are not measurements of any specific product or an industry average. For algorithm choice, follow current, widely accepted standards; for regulatory obligations, consult your legal counsel.
What Is Data Encryption?
Data encryption converts readable data (plaintext) into an unreadable form (ciphertext) using a key, so that only someone holding the right key can reverse it. Without the key, ciphertext is a meaningless sequence of bytes.
Two directions need to be kept apart: encryption in transit (data moving across a network) and encryption at rest (data sitting on disk, in a database or in a backup). One does not replace the other. This article also does not replace authentication and authorization: who can sign in is covered in our MFA and SSO guide, and what a signed-in user may see in our role-based access control guide. Encryption is the last layer, the one that matters when those doors are passed or when data leaves them altogether.
We recommend reading: What is secure software development? Threat model, scanning and a pre-release checklist
What Is the Difference Between Symmetric and Asymmetric Encryption?
Symmetric encryption uses the same key to encrypt and decrypt; asymmetric encryption uses a key pair, one that can be shared with anyone and one that stays secret. In practice the two are used together.
| Topic | Symmetric | Asymmetric |
|---|---|---|
| Key | One shared key | A public and a private key |
| Speed | Fast; suited to large data | Noticeably slower; suited to small data |
| Core problem | Sharing the key safely | Being sure the public key really belongs to that party |
| Typical use | Data on disk, in databases and in backups | Key agreement, digital signatures, certificates |
| Role in a connection | Encrypts the session data | Establishes the session key securely |
In transit, a session key is first agreed using the asymmetric method, and the actual data then travels under fast symmetric encryption. For data you store, symmetric keys are usually used as well; the asymmetric side comes in to protect keys and to sign.
How Do You Apply Encryption in Transit and at Rest?
Encryption in transit stops data from being intercepted as it moves between client and server and between services; encryption at rest stops a stolen disk, backup or database copy from being read. When choosing a level, write down which risk you are protecting against.
| Layer | Protects against | Does not protect against |
|---|---|---|
| Transit (TLS) | Eavesdropping and interception on the network | An authorized account reading data on the server |
| Disk or storage level | A stolen disk, a moved server, retired hardware | A user signed in to a running server, or an application flaw |
| Database level | A stolen database file or backup | An authorized account connected to the database |
| Field level (in the application) | A database administrator, a leaked copy or a badly written query, for selected fields | Someone who takes over the application itself (it can use the key) |
The most common mistake is switching certificate verification off in testing and forgetting it. Keep service-to-service and database connections encrypted too. For the other API measures, see our API security guide.
When Do You Need Field-Level Encryption?
Field-level encryption means encrypting only the sensitive fields (national ID number, tax number, bank account, a health note) inside the application and storing them that way. You need it where disk encryption is not enough.
Disk encryption decrypts data transparently on a running system, so a database administrator who can reach the server sees plaintext. A field encrypted at the application level stays encrypted in the database; the administrator, a leaked copy and a badly written report query cannot read it. The price is paid in two places: the application has to do the encrypting and decrypting, and searching, sorting and aggregating directly on the data becomes harder (see below).
What Is the Difference Between Password Hashing and Encryption?
Password hashing is one-way and cannot be reversed; encryption can be reversed with a key. Storing a password encrypted means that anyone who obtains the key can read it as plaintext.
| Topic | Password hashing | Encryption |
|---|---|---|
| Reversible? | No | Yes, with the key |
| What for? | Verifying a password without knowing its value | Protecting data that must be read later |
| Is there a key? | No; a random "salt" is added per password | Yes; managing it is the real work |
| Right example | A user's password | Tax number, bank account, a document |
| Wrong use | Hashing a phone number and trying to read it back | Encrypting a password and storing it |
The rule is simple: if the system never needs to read the value again (a password), hash it; if it does (showing an ID number on an invoice), encrypt it.
What Is Key Management and Why Is It the Hard Part?
Key management is the disciplined generation, storage, use, rotation and destruction of keys. Encryption is set up once; key management goes on every day.
- Separate storage: The key does not sit next to the data it encrypts; it is held in a dedicated key vault or a hardware-backed module. It is never written into the code repository or a configuration file.
- Access control: The account that can use a key is separate from the one that can manage it. The application that uses a key cannot manage it, and the person who manages it cannot read the data (separation of duties).
- Usage log: Every key use is logged. In the example normal use is ≈ 1,667 calls an hour (40,000 ÷ 24); a threshold at 5 times that (≈ 8,333) flags a mass-decryption attempt early.
- Rotation and destruction: Keys are changed at intervals; a retired key is deleted in a controlled way.
What Happens If a Key Is Lost? Key Loss Is Data Loss
Encrypted data does not come back without its key, to you or to anyone else. A single copy of the key is therefore as risky as a single copy of the data.
Representative example: the annual probability of losing a key is 2% with one copy, and recreating the data would cost ₺6,000,000. If the copies are kept in separate places and fail independently (this is an assumption), the probabilities multiply.
| Number of copies | Probability all are lost | Expected annual loss |
|---|---|---|
| 1 | 2% | 0.02 × ₺6,000,000 = ₺120,000 |
| 2 | 0.02² = 0.04% | 0.0004 × ₺6,000,000 = ₺2,400 |
| 3 | 0.02³ = 0.0008% | 0.000008 × ₺6,000,000 = ₺48 |
More copies also widen the exposure surface, so a key copy is not kept as a plain backup but split into parts, or in a form that several authorized people open together (for example 2 of 3 officers). Reaching the key during recovery is part of the plan too: add the time to retrieve the key to the RTO calculation in our disaster recovery guide.
What Is Envelope Encryption?
Envelope encryption encrypts the data with a data key and encrypts the data key with a higher-level key. The higher-level key (the key-encryption key) stays in the vault; the data key sits next to the data in encrypted form.
- For each group of records the application generates a data key and encrypts the data with it.
- The data key is wrapped (encrypted) with the higher-level key in the vault, and the wrapped version is stored next to the data.
- When reading, the application sends the wrapped key to the vault, the vault unwraps it with the higher-level key, and the application decrypts the data.
The benefit shows up in rotation. In a representative example, 200 GB of data is encrypted under 4,000 data keys. To change the higher-level key you only need to re-wrap each data key: 4,000 × 5 ms = 20,000 ms = 20 seconds. Re-encrypting the data from scratch at 100 MB per second would take 200 GB = 200,000 MB ÷ 100 = 2,000 s ≈ 33.3 minutes; so the envelope is about 100 times shorter (2,000 ÷ 20).
How Often Should Keys Be Rotated?
The rotation interval depends on the key type and on the impact if it leaks; what matters is frequency, automation and lifetime. The intervals below are an example company policy, not a requirement.
| Key type | Interval (representative) | Events per year | How it is done |
|---|---|---|---|
| Higher-level key | 12 months | 1 | Re-wrap the data keys |
| Data keys (4,000) | 12 months, staggered | 4,000 (≈ 333 a month) | New writes use a new key; old data follows as it is rewritten or through a bulk migration |
| Transport certificates (3) | 12 months | 3 | Renew before expiry, alert automatically |
| Application secrets (25) | 90 days | 25 × 4 = 100 | Generate a new secret, distribute it, close the old one |
Do not change all data keys on the same day: spreading 4,000 ÷ 12 ≈ 333 keys across each month spreads system load and error risk. The manually handled part is 1 + 3 + 100 = 104 events; at 30 minutes each, 104 × 30 = 3,120 min = 52 hours, and 52 × ₺300 = ₺15,600 a year. That is why secrets and certificates should be tied to automation.
What Is the Performance Impact of Encryption?
On current hardware, encrypting a single record takes a very small amount of time; the effect usually shows up in bulk operations and in connection setup. The measurements below are representative; do not decide without measuring your own system.
- A list page: 50 records × 3 encrypted fields = 150 decryptions; at 0.02 ms each that is 3 ms. The page goes from 120 ms to 123 ms, which is +2.5%.
- A bulk export: 200,000 records × 3 fields = 600,000 decryptions × 0.02 ms = 12,000 ms = 12 s. The export goes from 40 s to 52 s, which is +30%. The effect is clear in bulk work; schedule it for a night window.
- Connection setup: Say each encrypted handshake adds 40 ms. If you make 25 requests on a new connection each time, that is 25 × 40 = 1,000 ms; if you reuse the same connection there is one handshake, 40 ms. The difference is 25 times, or 40 ÷ 25 = 1.6 ms per request.
Test behavior under load with the method in our performance testing guide.
How Do You Search and Sort Encrypted Fields?
When a field is encrypted, the database does not understand the value, so it cannot search, sort or run range queries directly. The solutions are conceptual, and each has a price.
| Need | Approach | Price |
|---|---|---|
| Exact match (find a customer by tax number) | Keep a keyed search digest in a separate column and search on the digest | The same value gives the same digest; on low-variety fields (province, status) frequency information leaks, so do not use it there |
| Partial display (last four digits) | A separate masked field for display; the full value stays encrypted | An extra field is an exposure surface; keep it short |
| Sorting and ranges (amount, date) | Do not encrypt this field, or separate the sensitive part; if needed, process the result in the application | Database-level protection decreases; rely on the other layers |
| Full-text search | Move the searchable part into a separate, less sensitive field | The data design changes |
Searching by decrypting every row looks easy but does not scale: for 40,000 records, 40,000 × 0.02 ms = 800 ms; for 1,000,000 records, 20,000 ms = 20 seconds. A query through a search digest takes about 2 ms thanks to an index (representative); 800 ÷ 2 = 400 times faster.
How Do You Encrypt Backups?
A backup is often less protected than live data and travels more; so it should never leave unencrypted. Do not store the key next to the backup.
- Compress first, then encrypt: Encrypted data does not compress. In the representative example 200 GB shrinks to 120 GB through compression (−40%); encryption then takes 120,000 MB ÷ 100 = 1,200 s = 20 min, which is 13.3 min shorter than encrypting the 200 GB, and storage falls by 80 GB.
- Give the backup its own key: Do not tie it to a single point in the same vault as the live system's key; but do not keep it so far away that you cannot reach it at recovery time.
We covered RPO and RTO calculation, the 3-2-1 rule and restore testing in our data backup guide; encryption is a layer added on top of it.
How Do You Compare the Cost of Encryption with the Loss from a Breach?
Compare through expected annual loss: probability × impact. Encryption does not reduce the probability; it reduces the impact if a breach happens. The assumptions below are representative.
- 40,000 records containing personal data; if a breach occurs, the handling cost per record is ₺250 (notification, call handling, consulting), so 40,000 × ₺250 = ₺10,000,000.
- The probability that a copy leaks is 4% a year. An unencrypted copy is fully readable; for an encrypted copy whose key stays elsewhere the impact is 5% (metadata, some chance the key is affected too): ₺500,000.
- Setup is 30 person-days × ₺9,000 = ₺270,000; annual operation (key service, monitoring, maintenance) is ₺60,000.
| Item | Unencrypted | Encrypted |
|---|---|---|
| Loss in a breach | ₺10,000,000 | ₺500,000 |
| Expected annual loss (×4%) | ₺400,000 | ₺20,000 |
| Annual operation | — | ₺60,000 |
| Net annual benefit | ₺400,000 − ₺20,000 − ₺60,000 = ₺320,000 | |
Payback time: ₺270,000 ÷ ₺320,000 = 0.844 years ≈ 10.1 months. If the probability falls to 1%, the expected losses become ₺100,000 and ₺5,000; the net benefit is ₺95,000 − ₺60,000 = ₺35,000, and payback is 270,000 ÷ 35,000 = 7.7 years ≈ 92.6 months. The probability that just covers the annual operating cost is 60,000 ÷ (0.95 × 10,000,000) ≈ 0.63%. The calculation excludes fines, reputation and legal consequences; consult your legal counsel on those. Read the risk arithmetic together with our penetration testing guide.
We recommend reading: How to Design an Audit Log: Event Schema, Immutability, Retention and Payback Guide
We recommend reading: What Is Data Masking and Anonymization? Test Data, Pseudonyms, k-Anonymity and Payback Guide
We recommend reading: How to Design Secure File Upload and Storage: Validation, Scanning, Signed Links and Cost Guide
We recommend reading: How to Set Up Secrets Management: Inventory, Vault, Rotation, Short-Lived Credentials and Leak Response Guide
Secure Custom Software with İnovabil
At İnovabil our focus is building software from scratch, tailored to the company: custom software, ERP, CRM, e-commerce, web, mobile and integration. Our recorded capabilities include role-based access, audit logs and secure hosting; we recommend writing down decisions such as which data is encrypted and where the keys live during the requirements phase.
We have built CRM, purchasing and mobile for Avcılar İnşaat; a purchasing system for İZBAN; logistics and shipment planning with wholesale order management for Karyak; and warehouse management plus a complaint and support management system for Sleepy. The figures in this article are representative and are not an encryption service or certification commitment. Send us a short summary of your data classes and systems and we will analyze it together.
We recommend reading: Our software development process: step by step from analysis to launch
Frequently Asked Questions
What is data encryption, in short, and what is it for?
It makes data unreadable using a key. A stolen disk, a leaked backup or network traffic that is being sniffed cannot be read without the key. It is applied in transit and at rest, separately.
Should passwords be encrypted or hashed?
Hashed. Hashing cannot be reversed and a random salt is added to each password; encryption can be reversed with a key. Storing a password encrypted gives plaintext to anyone who reaches the key.
Why is envelope encryption used?
To make changing the higher-level key cheap and to keep that key in the vault. In the example, re-wrapping 4,000 data keys takes 20 seconds, while re-encrypting 200 GB from scratch takes about 33.3 minutes.
Can we recover the data if we lose the key?
Generally no. Encrypted data does not come back without the key. That is why you need several separate, protected copies of the key and a recovery test.
Does encryption slow performance a lot?
For most work the effect is small; it becomes clear in bulk operations and when a new connection is opened for every request. In the representative example a list page rises by 2.5% and a 200,000-record export by 30%. Measure on your own system.