Cyber Security Encryption Basics

Encryption transforms readable plaintext into scrambled ciphertext using a key, so that only someone holding the right key can turn it back into readable information.

Three Core Terms

  • Plaintext — the original, readable message or data before anything is done to it (a text message, a file, a password).
  • Key — a piece of secret information that controls exactly how the transformation happens; different keys produce different results from the same plaintext.
  • Ciphertext — the scrambled output produced by applying the algorithm and key to the plaintext; without the correct key it should look like meaningless noise.

Encryption is meant to be reversible: given the correct key, you can always recover the original plaintext from the ciphertext. That's the core difference from hashing, covered later in this course, which is deliberately a one-way process. A well-designed encryption scheme also assumes the attacker already knows exactly which algorithm was used — its security should rest entirely on the secrecy of the key, not on keeping the method itself a secret. This idea is often called Kerckhoffs's principle.

A Toy Example: The Caesar Cipher

One of the oldest ciphers simply shifts every letter of the alphabet forward by a fixed number of positions — the shift amount is the 'key'. It's useful for building intuition about plaintext, key, and ciphertext, but it is not secure by any modern standard, since there are only 25 possible shift values to try.

A Caesar Cipher in Python

def caesar_encrypt(text, shift):
    result = ""
    for char in text:
        if char.isalpha():
            base = ord('A') if char.isupper() else ord('a')
            result += chr((ord(char) - base + shift) % 26 + base)
        else:
            result += char
    return result

print(caesar_encrypt("ATTACK AT DAWN", 3))
# Output: DWWDFN DW GDZQ
Note: Because a Caesar cipher only has 25 possible keys, an attacker can simply try every shift value in a fraction of a second — this is why it's a teaching example, not a real security control. Modern algorithms like AES use keys drawn from a space so large that trying every possibility is completely infeasible with current computing power.

Encryption at Rest vs In Transit

AspectEncryption at RestEncryption in Transit
What it protectsData stored on disk, in a database, or in a backupData moving across a network right now
Typical exampleA full-disk-encrypted laptop or an encrypted database columnHTTPS traffic, or a VPN tunnel
Main threat it defends againstSomeone stealing the physical drive or backup mediaSomeone intercepting traffic on the network path

Why Key Length and Secrecy Matter

The strength of a modern cipher comes almost entirely from two things: how large the key space is (how many possible keys an attacker would have to try) and how well that specific key is kept secret. A large key space makes brute-force guessing computationally hopeless, while a leaked key defeats even the strongest algorithm instantly — the math doesn't matter if the key itself is exposed.

Note: Never invent your own encryption algorithm or 'obfuscation' scheme for anything real. Use well-reviewed, standard algorithms and libraries (like AES, covered in the next lesson) — cryptography that hasn't been publicly scrutinized for years tends to have subtle flaws that only become obvious once it's already been broken.