Cryptography

(WORK IN PROGRESS) On this page, we'll go from the absolute basics of cryptography up to the golden standards of modern security. We'll go through examples and introduce concepts one by one. Each level contains challanges, so you can verify you understood correctly. I hope you find it useful and learn something new!

Level 1: Substitutions

These are the most basic and easy ciphers, such as the Ceasar and the Atbash ciphers. They are very easy to understand and use, but not considered safe by themselves. I'll walk you through an example of the use a standard Caesar cipher. Let's consider the following scenario:
Fox wants to send Wolf a secret message on a piece of paper. He gets all of the letters in his message and then replaces (substitudes) each letter with the letter three places to the right of it in the alphabet. "A" becomes "D", "B" becomes "E" and so on. In case of an overflow we wrap back around, meaning "Z" becomes "C".

Fox takes his message (plaintext) "Hello Wolf" and encodes this message using the Ceasar cipher. The result is the encoded message (ciphertext) "Khoor Zroi". Fox told Wolf they will use the Ceasar cipher and shift by three characters to the right, so Wolf takes the encrypted message (ciphertext) and converts it back to the original message (plaintext) by shifting every letter three spaces to the left.
Fox recieved a reply. What does it say? Try decipher it and then press Reveal:

Ceasar cipher substituion table:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC

Khbd Ira

The Atbash cipher works by reversing the alphabet and mapping each letter to the original. "A" becomes "Z" and "Z" becomes "A", "B" becomes "Y" and "Y" becomes "B" and so on.

Atbash cipher substitution table:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYXWVUTSRQPONMLKJIHGFEDCBA

The Caesar and Atbash ciphers are very easy to break, because they follow an easy rule. By knowing just a bit of plaintext, or bruteforcing every possible shift and checking for valid english words, we can find the key and crack the whole ciphertext.

We can solve this issue by using a table with "random" substitutions. This solves the issues of regular substitution and makes the cipher much harder to break. In modern cryptography, almost every substitution cipher is irregular.

All of these ciphers are unsafe by themselves because they preserve the frequency of the letters used. We know that E is the most used letter in english text, so if we see X the most in our ciphertext, we can assume the mapping of E to X. With a long enough ciphertext, we can essentially figure out the whole cipher key table just by using their frequencies and a bit of guesswork. We call this method Frequency analysis.


Key takeaways from level 1:

- Plaintext    = The original message we want to send
- Ciphertext = The encrypted message
- Key = Information needed to decode the cipher (ex. How many characters we shift by.)
- Substitution = Replacing a character with a different one, using some rule or table (our key)