---
title: "Encryption Protects Stored Files | FiveStudy"
description: "What encryption is, plaintext, key, ciphertext, and keyspace, and how algorithms are classified as symmetric or asymmetric and as block or stream."
url: https://fivestudy.com/guides/ap-cybersecurity-5-3-a-encryption-protects-stored-files
---

[AP Cybersecurity](https://fivestudy.com/ap-cybersecurity) · Study guide

# Encryption Protects Stored Files

[Figure: FiveStudy]

FiveStudy

AP® Cybersecurity · Unit 5 · Applications, Data & Cryptography

AP® Cybersecurity · Unit 5 · Applications, Data & Cryptography

# Encryption Protects Stored Files

What encryption is, the words for its parts (plaintext, key, ciphertext, keyspace), and the two ways to classify algorithms: one key or two, block or stream.

1. Why encrypt a file 2. Plaintext, key, ciphertext 3. Keyspace 4. Symmetric and asymmetric 5. Block and stream 6. Worked examples 7. Common mistakes

## 1 Why encrypt a file

The purpose of **cryptography** is to hide information. A stolen laptop, a lost USB drive, or a copied backup exposes every file on it, unless those files are encrypted. **Encryption** hides the information; **decryption** reverses the encryption to get the original back. A **cryptographic algorithm** defines the process for both.

## 2 Plaintext, key, ciphertext

An encryption algorithm combines the information to be encrypted with a **key**. The input is the **plaintext**; the output is the **ciphertext**. Here is a very simple algorithm, shifting every letter forward in the alphabet by the key:

| Part | Value | Role |
| --- | --- | --- |
| Plaintext | `MEET AT NOON` | The readable information to protect |
| Algorithm | Shift each letter forward | The public process; everyone may know it |
| Key | `7` | The secret value that controls the result |
| Ciphertext | `TLLA HA UVVU` | The scrambled output that is safe to store |

Shifting back by 7 recovers `MEET AT NOON`. The algorithm can be public; the security comes from keeping the key secret.

## 3 Keyspace

The number of possible keys an algorithm can use is its **keyspace**. The larger the keyspace, the longer it takes an adversary to find the right key by trying them. The shift cipher has only 25 useful keys, so trying all of them takes seconds by hand:

Trying every key on the ciphertext

```
key  1:  SKKZ GZ TUUT
key  2:  RJJY FY STTS
key  3:  QIIX EX RSSR
key  4:  PHHW DW QRRQ
key  5:  OGGV CV PQQP
key  6:  NFFU BU OPPO
key  7:  MEET AT NOON   ← readable
key  8:  LDDS ZS MNNM
key  9:  KCCR YR LMML
  ...
key 25:  UMMB IB VWWV
```

Real algorithms use binary keys. Each extra bit doubles the keyspace. At a trillion guesses per second:

| Key length | Keyspace | Time to try every key |
| --- | --- | --- |
| 8 bits | 2^8 = 256 | less than a second |
| 40 bits | 2^40 = 1,099,511,627,776 | about 1 second |
| 56 bits | 2^56 = 72,057,594,037,927,936 | about 1 day |
| 128 bits | 2^128 = about 3.4 × 10^38 | about 1.1 × 10^19 years |
| 256 bits | 2^256 = about 1.2 × 10^77 | about 3.7 × 10^57 years |

A 56-bit key falls in about 1 day at that speed; a 128-bit key would outlast the universe many times over.

## 4 Symmetric and asymmetric

Algorithms are classified by whether they use one key or two:

- **Symmetric** algorithms use the *same* key to encrypt and decrypt. Anyone who can decrypt can also encrypt.
- **Asymmetric** algorithms use two *different* keys: one to encrypt and the other to decrypt.

**Figure 1.** Symmetric algorithms use one shared key for both directions. Asymmetric algorithms use a pair: what one key locks, only the other unlocks.

## 5 Block and stream

Algorithms are also classified by how they move through the information:

- **Block** encryption handles information in fixed-size chunks called **blocks**, producing one output block for each input block.
- **Stream** encryption handles input continuously, producing output one element at a time.

A block cipher with 16-character blocks would split the 34-character message `Rehearsal moved to Room 214, 4 PM.` like this:

| Block | Contents | Characters |
| --- | --- | --- |
| 1 | `Rehearsal moved` | 16 |
| 2 | `to Room 214, 4 P` | 16 |
| 3 | `M.` | 2 |

The last block has only 2 characters, so 14 characters of **padding** fill it to full size before it is encrypted. A stream cipher needs no padding; it encrypts each character as it arrives, which suits live data such as a phone call.

The key idea

Encryption combines plaintext with a key to produce ciphertext, and decryption reverses it. A larger keyspace means a longer search for the key. Symmetric algorithms use one key, asymmetric use two; block ciphers work in fixed chunks, stream ciphers one element at a time.

## 6 Worked examples

Worked Example 1 Name the parts

### The locked report

A nurse saves `visit-notes.txt` as `visit-notes.enc` using an app and a secret key. Name the plaintext, the ciphertext, and what someone needs to read the notes again.

1. 1

   Plaintext: the readable `visit-notes.txt`.

2. 2

   Ciphertext: the scrambled `visit-notes.enc`.

3. 3

   To decrypt, a person needs the algorithm (known) and the key (secret).

**Answer:** Plaintext is the original, ciphertext is the .enc file, and the key is what unlocks it.

Worked Example 2 Compare keyspaces

### Two more bits

Cipher A uses 40-bit keys. Cipher B uses 42-bit keys. How many times longer does it take to try every key for B?

1. 1

   Each extra bit doubles the keyspace.

2. 2

   Two extra bits: 2 × 2 = 4.

3. 3

   2^42 ÷ 2^40 = 4.

**Answer:** Four times as long. Adding bits grows the search very quickly.

Worked Example 3 Classify the algorithm

### One key or two? Block or stream?

An algorithm encrypts data 128 bits at a time, and the same key that encrypts a file also decrypts it. Classify it both ways.

1. 1

   The same key encrypts and decrypts: symmetric.

2. 2

   It works on fixed 128-bit chunks: block.

**Answer:** A symmetric block cipher, which is how AES is described.

Worked Example 4 Explain the protection

### The lost USB drive

A club's USB drive with member phone numbers is lost. The file on it was encrypted with a strong key that is not stored on the drive. What can the finder learn?

1. 1

   The finder has the ciphertext only.

2. 2

   Without the key, they must try keys; a strong key's keyspace makes that take far too long.

3. 3

   The phone numbers stay hidden.

**Answer:** Nothing useful. Encryption protects files even after the device is lost, as long as the key stays secret.

## 7 Common mistakes

Common Mistake 1 · Thinking the algorithm must be secret

Strong algorithms are public. The key is what must stay secret.

Common Mistake 2 · Thinking keyspace grows a little with each bit

Each bit doubles it. 128 bits is not twice as strong as 64 bits; it is 2^64 times larger.

Common Mistake 3 · Mixing up the two classifications

Symmetric or asymmetric is about the number of keys. Block or stream is about how data is processed. An algorithm has one of each label.

Explain file encryption like this

“Encrypting the file combines its plaintext with a secret key to produce ciphertext. Someone who steals the file sees only the ciphertext, and with a 128-bit key the keyspace is so large that trying every key is not practical.”

Name the plaintext, the key, and the ciphertext, and connect the key length to how hard the key is to find.

FiveStudy AP® Cybersecurity · Encryption Protects Stored Files
