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 GDZQEncryption at Rest vs In Transit
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.