Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 3

Understanding Encryption, Decryption, and Keys

Recommended resources

Welcome back! In our first two lessons, we defined the field of cryptography and drew a sharp distinction between scrambling a message's content (cryptography) and hiding its existence (steganography). We now have a high-level map of the world of secret communication. Today, we'll zoom in and examine the fundamental engine that powers every cryptographic system.

Our goal is to understand the core process of scrambling and unscrambling a message. To do this, we will define the precise roles of encryption, decryption, and the all-important key. These three concepts form the bedrock of everything that follows, from ancient ciphers to the secure protocols that protect your data online.

The Vocabulary of Secrecy

Before we can analyze how a cryptographic system works, we need to agree on a common vocabulary. Any act of secret writing involves transforming a readable message into a secret one, and then back again. Let's watch a brief clip that lays out these fundamental terms.

Cryptography Crash Course Computer Science #33

This segment from the Crash Course Computer Science series on Cryptography provides a quick and clear set of definitions for the basic components of any cryptosystem.

Watch the clip from "The word cryptography..." to the end of the definitions. Pay close attention to the distinction between the process (encryption/decryption) and the result (ciphertext).

To solidify these concepts, let's look at a more formal set of definitions. As an analytics engineer, you'll appreciate the value of precise terminology.

An Introduction to Cryptography - IDPro Body of Knowledge

This article from the IDPro Body of Knowledge includes a helpful terminology table. It's a great reference for the formal language of cryptology.

Review the table in the Terminology section. Specifically, focus on the definitions for: Plaintext (or Cleartext) Ciphertext Encrypt (or Encipher) Decrypt (or Decipher) Key

So, to summarize our core process: we take plaintext, apply an encryption algorithm to it, and produce ciphertext. To recover the original message, we apply a decryption algorithm to the ciphertext, which returns it to plaintext.

But what prevents anyone who intercepts the ciphertext from simply running the decryption process themselves? This is where the most crucial element comes into play: the key.


The Key: The Secret to Security

The "secret" in "secret writing" is not typically the algorithm. In fact, for modern systems, the algorithm is almost always public knowledge, allowing experts worldwide to test it for weaknesses. The security of the entire system rests on a small piece of information that is shared only between the sender and the intended recipient: the key.

The key is the variable that controls the output of the encryption algorithm. Without the correct key, decrypting the ciphertext is designed to be practically impossible. Let's see this in action with one of the first ciphers we discussed, the Caesar cipher.

Encryption, decryption, and cracking (article) | Khan Academy

This Khan Academy article uses the Caesar cipher to beautifully illustrate the distinct roles of encryption, decryption, and the key.

First, read the sections "Encrypting a message" and "Decrypting a message". Notice how the shift value (e.g., 3 or 6) is the key that enables both processes. Finally, read the concluding section, "Encryption, decryption, and cracking". It provides a perfect summary of the three roles we are focused on.

As the article makes clear, the key is the linchpin of the entire system. You can know the method (e.g., "shift the letters of the alphabet") but without the key (e.g., "shift by 3"), the ciphertext remains gibberish. This is the central plot device in countless mystery and spy stories: the heroes have intercepted a secret message, but it's useless until they can find, steal, or deduce the key.


Two Models for Keys: A Sneak Peek

All cryptographic systems rely on keys, but they don't all use them in the same way. Over the centuries, two major models for managing keys have emerged. Understanding the difference is fundamental to grasping modern cryptography.

1. Symmetric Key Cryptography

This is the intuitive model, the one used by Caesar and in countless systems since. A single key is used for both encryption and decryption. Think of it like a key to your house: the same key locks the door and unlocks it. Both the sender and receiver must have a copy of the same secret key.

The image below shows this process. The same key is used on both ends.

This diagram illustrates symmetric encryption. The sender uses a key to encrypt the plaintext into ciphertext. The receiver uses the exact same key to decrypt the ciphertext back into the original plaintext.

All the historical ciphers we will study in the next few modules are symmetric. Their strength depends entirely on keeping that single key a secret.

2. Asymmetric Key Cryptography (Public Key Cryptography)

This is a more modern and mind-bending concept that is the foundation of internet security. In this model, you don't have one key; you have a pair of mathematically linked keys.

  • A Public Key that you can share with anyone. This key can only be used to encrypt messages (lock the box).
  • A Private Key that you keep absolutely secret. This key is the only one that can decrypt messages encrypted with your public key (unlock the box).

This solves a huge problem: how do two people who have never met share a secret key without an eavesdropper intercepting it? With asymmetric cryptography, they don't have to. Let's watch a fantastic analogy that makes this clear.

Encryption and public keys | Internet 101 | Computer Science | Khan Academy

This Khan Academy video provides one of the best analogies for understanding public and private keys: the mailbox.

Please watch the segment from the introduction of asymmetric keys through the end of the mailbox analogy. This perfectly illustrates how one key can be public without compromising the security of the private one.

The video's analogy is powerful. Anyone can drop a letter in the mailbox (encrypt with the public key), but only the person with the private key can open it and read the mail (decrypt).

The diagram below visualizes this flow, showing "Alice" sending a message to "Bob" using his public key.

This diagram shows the process of asymmetric or public key encryption. The sender (Alice) uses the recipient's (Bob's) public key to encrypt a message. Only the recipient, using their corresponding private key, can decrypt it.

We will dive much deeper into both symmetric and asymmetric systems in later modules, but for now, it's important to recognize these two fundamental approaches to using keys.


Conclusion

In this lesson, we've unpacked the core mechanics of a cryptographic system. You now have a clear understanding of the essential components and their roles.

Here are the key takeaways:

  • Encryption is the process of converting readable plaintext into unreadable ciphertext.
  • Decryption is the reverse process of turning ciphertext back into plaintext.
  • The key is the secret piece of information that controls the encryption and decryption process. The security of the system relies on the secrecy of the key, not the secrecy of the algorithm.
  • In Symmetric Cryptography, a single shared key is used for both encryption and decryption.
  • In Asymmetric Cryptography, a public key is used to encrypt, and a different, private key is used to decrypt.

We've used the terms "cipher" and "algorithm" to describe the method of encryption. But you may have also heard the word "code" used in this context. Are they the same thing? In our next lesson, we will explore the classic and important distinction between codes and ciphers.