Challenge: Caesar of Rome 🏰

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.

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. Hence, 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.

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

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

Your tasks in this challenge are:

  1. Read the encrypt(plaintext, key) function and make sure you understand why we are using the if condition there.
  2. Then, once you understand that, complete the decrypt(ciphertext, key) function so that it returns "checkflank".

Test case

You need to pass this challenge to go to the next lesson. Good luck!

📈 Please, fill a short feedback form designed for this lesson. We love you!

Console output