Applied Crypto
Cryptography Foundations

Encryption and the Meaning of Secure

Turn a readable message into ciphertext, discover why a simple cipher fails, and learn what a meaningful claim of cryptographic security must say.

YOUR MISSION

Trace what encryption changes, what must stay secret, and what an attacker can try.

Check each one off when you can do it without looking at your notes. Saved in this browser.

TRY IT IN YOUR BROWSER

Turn the Caesar wheel.

Change the message and key, then switch direction. The workbench makes every part of the encryption system visible.

CIPHERTEXTPHHW PH LQ WKH ODE
P+K=3C

The algorithm stays the same. The key changes which transformation is applied.

ATTACKER MODE

Try every key.

You intercepted MCTYR JZFC YZEPD. Test keys one at a time until the output becomes meaningful English.

0 of 25 keys tested
SELECT A KEYThe candidate plaintext will appear here.

Why do this? Caesar has only 25 useful keys. An attacker can systematically test each one instead of guessing the secret.

KEY ARRANGEMENT CHECK

Symmetric, asymmetric, or neither?

Decide what kind of system the description represents.

SCENARIO 1 OF 4Two servers use the same secret key to protect a large backup.
0correct
DESIGN CHECK

What should remain secret?

Assume an attacker knows exactly how the cipher works.

CLAIM CLINIC

Repair this vague claim.

“The database is encrypted, so it is secure.”

A useful claim names a goal, a boundary, and an attacker.

1. Security goal
2. Boundary
3. Attacker
01UNDERSTAND

Begin with a locked message

Imagine that a classmate slides this note across the table:

PHHW PH LQ WKH ODE

It does not look like ordinary English. Has the message been encrypted? Probably. Is it secure? That is a different question.

A readable message can be changed into an unreadable form with a simple rule. If an attacker can discover or try that rule quickly, the message is hidden only briefly. Cryptography is therefore not just about scrambling information. It is about protecting information against a clearly described attacker.

This topic establishes the vocabulary and reasoning used throughout the course.

Textbook connection: This lesson follows the foundations in Chapter 1 of Serious Cryptography, second edition. The chapter contains several advanced security models and constructions. We will build the concrete mental model first and return to the formal ideas as the course develops.

The basic encryption system

Encryption begins with information that someone wants to protect.

  • Plaintext is the original, readable information.
  • A cipher is the algorithm that performs encryption and decryption.
  • A key is a value that controls how the cipher transforms the information.
  • Ciphertext is the encrypted result.
  • Encryption transforms plaintext into ciphertext.
  • Decryption uses the appropriate key to recover the plaintext.

The basic path is:

plaintext + key → encryption → ciphertext
ciphertext + key → decryption → plaintext

Suppose the plaintext is MEET ME IN THE LAB and the cipher shifts every letter three places forward in the alphabet. The value 3 is the key. The resulting ciphertext is:

PHHW PH LQ WKH ODE

Decryption shifts each letter three places backward and returns the original message.

Encryption is not encoding

Encoding changes how information is represented so another system can store or transmit it. Base64 is an encoding. It uses a public, reversible procedure and no secret key.

Encryption is intended to protect information from someone who does not possess the required key. If a student changes hello into a Base64 string, the result may look unfamiliar, but anyone can reverse it. Unfamiliar text is not proof of encryption.

Operation Purpose Secret required? Example
Encoding Represent data in another format No Base64
Encryption Protect data using a cipher and key Yes, for the protected operation AES encryption
Hashing Produce a fixed-size digest No secret in an ordinary hash SHA-256

Hashing receives its own later topic. For now, remember that encryption is reversible with the proper key; an ordinary cryptographic hash is not designed to be reversed.

The Caesar cipher: useful for learning, unsafe for protection

The Caesar cipher shifts letters by a fixed number of positions. With key 3:

A → D
B → E
C → F
...
X → A
Y → B
Z → C

The key tells us how far to shift. A different key produces a different ciphertext.

The browser lab above lets you change the key and watch every letter move. This makes three ideas visible:

  1. The same plaintext and same key always produce the same ciphertext.
  2. Repeated plaintext letters produce repeated ciphertext letters.
  3. There are only 25 useful nonzero shifts to try.

That third fact breaks the cipher. An attacker does not need a clever mathematical shortcut. The attacker can try every possible shift and look for readable language. Trying an entire small set of keys is a brute-force search.

Worked example

Ciphertext:

KHOOR

Try shifting backward:

Candidate key Candidate plaintext
1 JGNNQ
2 IFMMP
3 HELLO

Once HELLO appears, the attacker has a strong candidate. Context can confirm it.

The lesson is not that all substitution is useless. The lesson is that a secure modern cipher needs a key space and internal structure too large and complex for an attacker to search or predict with practical resources.

Never use a Caesar cipher, Vigenere cipher, or a homemade cipher to protect real information. They are teaching models, not modern security controls.

A key is not the algorithm

Students often imagine that encryption works because outsiders do not know the method. That is fragile. Methods leak. Software can be inspected. Employees change jobs. Attackers can purchase the same product or read its documentation.

Kerckhoffs's principle says that a cryptographic system should remain secure even when the attacker knows how the system works. Security should depend on keeping the key secret, not on hiding the algorithm.

That principle lets the public examine and test widely used algorithms. A public algorithm is not automatically weak. AES is publicly documented. Its security depends on the key and correct use, not on pretending that no one knows AES exists.

Compare two claims:

Weak claim: “Our encryption is safe because no one knows our special algorithm.”

Better claim: “The algorithm is public and reviewed. Each authorized user receives a protected key, and an attacker who knows the algorithm still cannot feasibly recover the plaintext without that key.”

The better claim can still fail if keys are exposed or the algorithm is used incorrectly. Kerckhoffs's principle removes one dangerous assumption; it does not solve every implementation problem.

Symmetric and asymmetric encryption

There are two main key arrangements.

Symmetric encryption

In symmetric encryption, the same secret key is used to encrypt and decrypt, or the decryption key can be directly derived from the encryption key.

shared secret key → encrypt
shared secret key → decrypt

Symmetric encryption is fast and works well for protecting large amounts of data. The difficult question is how the authorized parties obtain and protect the shared secret.

Examples later in the course include AES and ChaCha20.

Asymmetric encryption

In asymmetric encryption, the keys are different:

  • A public key may be shared.
  • A private key must remain secret.

Someone can use a recipient's public key for an allowed public operation, while only the private-key holder can perform the corresponding private operation.

public key → encrypt for the owner
private key → decrypt

This is a simplified first model. Public-key systems also support digital signatures and key agreement, and real systems commonly combine asymmetric and symmetric techniques. RSA, Diffie-Hellman, and elliptic curves receive their own topics.

Question Symmetric Asymmetric
Key arrangement Shared secret Public/private pair
Main advantage Fast for large amounts of data Helps with key distribution and identity-related operations
Main challenge Sharing and protecting the secret More computation and more complex trust decisions
Later examples AES, ChaCha20 RSA, elliptic-curve systems

Data at rest and data in transit

Encryption is applied in different situations.

Data at rest is stored data: a file on a drive, a database record, or a backup. At-rest encryption helps if someone steals storage media or gains access to stored ciphertext without the key.

Data in transit is moving between systems: a browser request, a chat message crossing a network, or data sent to a cloud service. In-transit encryption helps prevent network observers from reading the traffic.

These protections do not automatically replace one another. A database may encrypt its disk while an export is emailed without transport protection. A secure network connection may protect traffic while the receiving computer saves the plaintext in an exposed folder.

Ask where the information is readable, where it is encrypted, who holds the key, and which attacker is being considered.

“Secure” is incomplete by itself

Saying “this cipher is secure” leaves important questions unanswered.

Name the security goal

What must the system protect?

  • Confidentiality: unauthorized parties should not learn the plaintext.
  • Integrity: unauthorized changes should be detectable.
  • Authenticity: the receiver should have evidence about who created the protected message.

Basic encryption aims primarily at confidentiality. Encryption alone does not automatically guarantee integrity or authenticity. Later topics introduce message authentication and authenticated encryption.

Name the attacker model

What can the attacker do?

  • See one or many ciphertexts?
  • Know part of the plaintext?
  • Choose information that will be encrypted?
  • Modify ciphertexts and observe errors?
  • Steal the device or read the key file?

A design may resist a passive observer but fail when an attacker can modify messages or obtain the key. A useful security statement therefore combines a goal with assumptions about the attacker.

Repair the claim

Vague:

“The customer database is encrypted, so it is secure.”

Improved:

“The database is encrypted at rest to protect customer records from someone who obtains a copy of the storage volume but does not obtain the encryption key. Access to the running application and theft of the key require separate controls.”

The improved version states:

  • what is protected;
  • where encryption applies;
  • what the attacker has;
  • what the attacker does not have; and
  • what remains outside the claim.

How encryption fails even when the idea sounds right

Common first failures include:

  • using an obsolete or homemade cipher;
  • choosing a key space that attackers can search;
  • storing the key beside the ciphertext with the same access permissions;
  • protecting data at rest but exposing it in transit;
  • assuming that hiding the algorithm creates security;
  • claiming confidentiality when the application also needs integrity; and
  • ignoring what the surrounding application reveals through errors or behavior.

Cryptography is part of a system. The cipher matters, but key handling, software behavior, protocols, users, and attacker access matter too.

What to carry forward

Use this five-question check whenever you encounter encryption:

  1. What is the plaintext?
  2. What is the ciphertext?
  3. What key or keys are involved?
  4. What security property is needed?
  5. What can the attacker realistically do?

If a security claim cannot answer those questions, it is not ready to trust.

The next topic examines randomness. Keys, nonces, and many cryptographic operations depend on values an attacker cannot predict. A strong cipher supplied with predictable “random” values can still fail.

02PRACTICE

Cipher rescue activity

Work with a partner. Use the browser lab above and record short explanations in your own notes. Nothing needs to be downloaded.

Part 1: Trace the system

For the example below, identify the plaintext, key, cipher, ciphertext, encryption direction, and decryption direction.

MEET AT FOUR --Caesar shift 3--> PHHW DW IRXU

Then answer:

  1. Which value must the receiver know to reverse the transformation?
  2. Which part is the algorithm?
  3. Which part is the protected output?

Part 2: Change the key

In the Caesar workbench:

  1. Enter a short message with at least one repeated letter.
  2. Encrypt it with shift 3.
  3. Encrypt the same message with shift 8.
  4. Compare the outputs.

Explain what changed, what stayed the same, and what repeated-letter pattern remains visible.

Part 3: Be the attacker

Open the brute-force challenge. Test candidate shifts one at a time for the supplied ciphertext.

  1. Select the candidate that produces meaningful English.
  2. State how many useful nonzero Caesar keys exist.
  3. Explain why the attacker does not need to know the key in advance.
  4. Explain why “the attacker does not know our shift” is a weak security claim.

Part 4: Choose the key arrangement

Classify each first-pass scenario as symmetric, asymmetric, or neither.

  1. A laptop encrypts its drive using a protected secret key.
  2. A sender uses a recipient's public key so only the recipient's private key can perform the corresponding private operation.
  3. Two systems already share one secret and use it to protect a large backup transfer.
  4. A file is converted to Base64 before it crosses a text-only system.

For each answer, state whether the system uses a shared secret, a public/private pair, or no encryption at all.

Part 5: Repair a security claim

Rewrite this sentence:

“Our files are secure because we encrypted them with a secret algorithm.”

Your improved statement must name:

  • the security goal;
  • whether the data is at rest or in transit;
  • what remains secret;
  • something the attacker may know or possess; and
  • one limitation outside the claim.

Pair explanation

Without reading the lesson, take turns explaining this chain:

plaintext + key → cipher → ciphertext → decryption → plaintext

The listener must ask: “Secure against what?” The speaker must answer with one security goal and one attacker capability.

03REVIEW

Encryption foundations review

Terms to know

Term Plain-language meaning
Plaintext Original readable information
Ciphertext Encrypted form of the information
Cipher Algorithm that performs encryption and decryption
Key Value that controls the cipher's transformation
Encryption Transforming plaintext into ciphertext using a cipher and key
Decryption Recovering plaintext from ciphertext with the appropriate key
Brute force Trying possible keys until a useful result appears
Symmetric encryption Encryption based on a shared secret key
Asymmetric encryption Cryptography based on a public/private key pair
Kerckhoffs's principle Security should depend on the key, not secrecy of the algorithm
Attacker model Assumptions about what an attacker can observe or do

Fast distinctions

If the prompt says... Think...
“Readable original message” Plaintext
“Protected output” Ciphertext
“Controls the transformation” Key
“Same shared secret protects and recovers data” Symmetric encryption
“Public key and private key have different roles” Asymmetric encryption
“The algorithm must remain hidden” Violates Kerckhoffs's principle
“Stored database or disk” Data at rest
“Traffic crossing a network” Data in transit
“It is secure” with no stated threat Incomplete security claim

Common mistakes

  • Ciphertext is not automatically secure merely because it looks unreadable.
  • Base64 encoding is not encryption.
  • The key and the cipher are different things.
  • Public knowledge of a well-designed algorithm is not the same as key exposure.
  • Symmetric does not mean “weak,” and asymmetric does not mean “always better.”
  • Encryption for confidentiality does not automatically provide integrity or authenticity.
  • At-rest protection does not guarantee in-transit protection.
  • A Caesar cipher is a learning tool, not an acceptable modern control.

Check yourself

  1. In C = E(K, P), what do C, E, K, and P represent?
  2. Why can an attacker break a Caesar cipher without learning a secret from its owner?
  3. What must remain secret under Kerckhoffs's principle?
  4. What is the main key-arrangement difference between symmetric and asymmetric encryption?
  5. Give one example of data at rest and one example of data in transit.
  6. Why is “military-grade encryption” not a complete security claim?
  7. Rewrite “the file is encrypted, so nobody can access it” as a more limited and testable statement.
  8. Why might storing the key next to the ciphertext defeat the intended protection?

Explain it aloud

You are ready to move on when you can say, without notes:

Encryption uses a cipher and key to transform plaintext into ciphertext. A useful security claim must say what property is protected and what the attacker can do. The algorithm may be public; the key and its handling carry the secret.

KEEP LEARNING

A scrambled message is not automatically a secure message.

If you can label plaintext, key, and ciphertext, break a Caesar cipher, and repair a vague security claim, you are ready to study secure randomness.