Lesson 5 of 7
Encryption
Understand how secret codes, ciphers, and modern public-key cryptography keep our digital world private.
Learn it
Encryption is the art of turning readable messages into scrambled secret codes that nobody can understand unless they have the secret key to unlock them.
Long ago, Julius Caesar used a simple shift cipher to send secret military orders. Today, computers use powerful mathematical algorithms to encrypt everything from your WhatsApp messages to online banking.
Without encryption, anyone sitting on the same public Wi-Fi network as you at a coffee shop could intercept and read your private passwords and photos in plain text!
Key terms
- Plaintext
- Original, unencrypted data that is fully readable by humans and computers.
- Ciphertext
- The scrambled, unreadable output produced after applying an encryption algorithm to plaintext.
- Symmetric Encryption
- An encryption method that uses the identical secret key for both encrypting and decrypting data.
- Asymmetric Encryption
- A cryptographic system using a public key for encryption and a distinct private key for decryption.
Understanding the Caesar Cipher Shift
Explore how shifting the alphabet creates one of the oldest encryption algorithms in history.
- 1Select a Key: Choose a numeric shift value (for example, Shift = 3).
- 2Write the Plaintext: Take a word to encrypt, such as 'DEFEND'.
- 3Shift Each Letter: Move each character forward by 3 positions in the alphabet: D becomes G, E becomes H, F becomes I, and so on.
- 4Produce Ciphertext: The plaintext 'DEFEND' transforms into the ciphertext 'GHIHQG'.
- 5Reverse with Key: To decrypt, shift backward by 3 positions using the secret key.
Caesar Cipher in Python
pythondef caesar_encrypt(plaintext, shift):
result = ''
for char in plaintext.upper():
if char.isalpha():
# Shift within A-Z range (ASCII 65-90)
shifted = chr((ord(char) - 65 + shift) % 26 + 65)
result += shifted
else:
result += char
return result
print(caesar_encrypt('CYBER', 3)) # Output: FBEHUThis Python function shifts every uppercase letter along the 26-letter English alphabet by a chosen shift value using modular arithmetic.
Sandbox lab
Practise the real technique in a fully simulated environment — no live systems, no real data, nothing leaves your browser.
Cipher-breaking workbench
Break an intercepted message offline. Nothing leaves your browser — the ciphertext is fictional.
WKH VHFUHW PHHWLQJ LV DW WKUHH SP LQ WKH VHUYHU URRP
Decryption attempt
WKH VHFUHW PHHWLQJ LV DW WKUHH SP LQ WKH VHUYHU URRP
Letter frequency in the ciphertext (English order: ETAOIN…)
Tip: the most common ciphertext letter probably maps to E or T. A Caesar shift of 3 was Julius Caesar's own choice.
Try it
What will be the output of this Python Caesar cipher code when shifting the word 'CAB' by 2?
pythonword = 'CAB'
shift = 2
result = ''.join(chr((ord(c) - 65 + shift) % 26 + 65) for c in word)
print(result)Challenge
Explain why Caesar ciphers are completely unsuitable for modern cybersecurity.
Pick whichever way suits you — every mode earns the same bonus XP.
Write at least 40 more characters to submit.
Mark your own work
Guided walkthrough — 0/5 clues revealed
- Clue 1 locked — reveal it only if you get stuck.
- Clue 2 locked — reveal it only if you get stuck.
- Clue 3 locked — reveal it only if you get stuck.
- Clue 4 locked — reveal it only if you get stuck.
- Clue 5 locked — reveal it only if you get stuck.
Each clue costs 5 XP (never below 23 XP). You'd earn 45 XP right now.
Extension: Describe the Diffie-Hellman Key Exchange and how two parties can establish a shared secret over an insecure channel.