1. Home
  2. Explore
  3. Computer Science
  4. Secret-Key Encryption

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Secret-Key Encryption

Speaker 1Speaker 2

Secret-Key Encryption

4:07
0:00-4:07
  1. Hope

    Today we’re looking at secret-key encryption. Let’s begin with the basic idea: encryption encodes information to protect it from unauthorized access. The original information is called plaintext, and the encoded result is called ciphertext.

  2. Corey

    And decryption reverses that process: it takes ciphertext and recovers the plaintext. Both processes use a key, which helps determine how the information is transformed.

  3. Hope

    There are two broad approaches based on how those keys relate. In secret-key encryption, the same key is used for encryption and decryption, so it’s also called symmetric-key cryptography. In public-key encryption, the encryption key and decryption key are different, which is why it’s also called asymmetric-key cryptography.

  4. Corey

    For this episode, we’ll focus on the secret-key approach with a simple example. We’ll encrypt the word “attack” using XOR, a bit-level operation. XOR outputs zero when the two input bits are the same, and one when they’re different.

  5. Hope

    So the four possible inputs are easy to remember: zero XOR zero gives zero, zero XOR one gives one, one XOR zero gives one, and one XOR one gives zero. In short, XOR marks whether the bits differ.

  6. Corey

    To work with the letters, we represent them as bytes using ASCII. The word “attack” has the hexadecimal byte values 41, 54, 54, 41, 43, and 4B. For example, the first letter, A, is 41 in hexadecimal.

  7. Hope

    Now we need a secret key. In this demonstration, the key is the single byte 73 in hexadecimal, or 01110011 in binary. We repeat that same key byte for each byte of the plaintext, then XOR each pair to produce the ciphertext.

  8. Corey

    Let’s do the first byte. The plaintext byte 41 XOR the key byte 73 gives 32 in hexadecimal. Applying the same operation to the other letters gives 27, 27, 32, 30, and 38. So the ciphertext bytes are 32 27 27 32 30 38.

  9. Hope

    That sequence doesn’t directly read as “attack,” because it’s encoded rather than plain text. The important thing is that both sides can use the shared key and the agreed XOR operation to recover the original bytes.

  10. Corey

    Here’s the neat part: XOR is its own reverse. If you XOR a plaintext byte with the key to encrypt it, then XOR the result with that same key, you get the plaintext back. For example, 41 XOR 73 gives 32, and 32 XOR 73 gives 41.

  11. Hope

    So the receiver takes each ciphertext byte, repeats the key byte 73, and XORs the two. Doing that across the whole ciphertext returns 41 54 54 41 43 4B, which represents “attack.” The same key is used on both sides, which is exactly what makes this a secret-key example.

  12. Corey

    But this example is for learning the idea, not for protecting real information. It’s very weak: if someone knows even one matching plaintext byte and ciphertext byte, they can XOR them to recover the key byte. In our example, 41 XOR 32 reveals 73.

  13. Hope

    And the key here is only one byte, repeated over and over, which makes the demonstration especially simple—and especially insecure. Practical encryption algorithms are much more complex and use longer keys.

  14. Corey

    There’s also a difference in how much data an algorithm handles at once. This example applies the operation byte by byte, which the source describes as a stream-cipher approach. Other algorithms process data in blocks, and those are called block ciphers.

  15. Hope

    So the key takeaways are: encryption turns plaintext into ciphertext, decryption reverses it, and secret-key encryption uses the same key for both. XOR gives us a clear demonstration of how that can work—and its weaknesses remind us why real encryption needs stronger algorithms and longer keys.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent