2. Challenge: Caesar's cipher 🏰

Caesar's cipher is the most famous symmetric key encryption algorithm. It was used by the Julius Caesar of Rome for military communications.

It works by replacing a letter with another letter by some fixed number of position. It's better understood with an example.

Suppose, we want to encrypt "hey". And the fixed number of position for replacement is 2.

Hey encryption via caesar cipher
Caesar cipher's encryption process. Click to zoom.

Let's write the english alphabets:

a b c d e f g h i j k l m n o p q r s t u v w x y z

The letter two places ahead of h is j. Hence, h becomes j.

Similarly, e becomes g.

Now, there's no letter ahead of two places of y, so we go to the beginning. And y becomes a.

The fixed number of position is the encryption key.

Finally, encrypting the plaintext hey with key 2 will result in ciphertext jga.

If you look at the above image, the caesar's cipher encryption process should now make sense.

To decrypt, instead of going forward number of positions, we go backwards. So while decrypting, jga will become hey.

Challenge

If bob is the plaintext. And ciphertext is ere. What's the key?

5
3

You see how easy it was to figure out the key of Caesar cipher.

Now a days, we use safe symmetric encryption algorithms like AES (Advanced Encryption Standard). AES is designed in such a way that even if the attacker knows the ciphertext and plaintext, it is practically not feasible to figure out the key. Because brute-forcing AES's key would take a long long time making it practically non-feasible.

Go to next lesson: Cryptographic hash functions