Tags: crypto crytography 

Rating:

# Hail Caesar! (10 points)
Flag format: `flag{...}`
## Challenge
This image was found in Ghost Town along with the encoded message below. See if you can decipher the message. Enter the entire decoded message as the flag.

Decode this: **TGG KUSJWV QGM**

![](https://cyberhacktics.sfo2.digitaloceanspaces.com/crypto/crypto01/crypto01.png)
## Solution
The original text was encrypted using **Shift Cipher** technique or also known as **Caesar Cipher**. It involves replacing each letter in the message by a letter that is some fixed number of positions in the alphabet. The letters are 'shifted' by some number of spaces to the left or right in alphabet. Decryption is performed using reverse direction shifts. This number of spaces/shifts is called *key*. For example, in the case of this challenge, according to the image above it is a right shift of 18 meaning that `key = 18` and each letter is replaced by a letter which is to the right by 18 positions(e.g. letter S replaces A because it is 18 positions to the right of A's position):
```
Position: 0 1 2 3 4 5 6 7 8 9 . . . 18 19 . . .
Original alphabet: 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
Shifted alphabet: S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
```
Based on this we can decipher the encrypted message:
```
Encrypted text: TGG KUSJWV QGM
Decrypted text: BOO SCARED YOU
```
Shift Ciphers work by using the *modulo operator* to encrypt and decrypt messages performing modulo arithmetic:
```
Encryption: (X + key) mod 26
Decryption: (X - key) mod 26
```
Where *X* stands for letter position, '+' shift to the right and '-' shift to the left. Modulo arithmetic is used for the cases when after performing *shifts* *X<0* and *X>25* in order to keep letter position in range 0-25. For example, letter B in original message was replaced with T: `(1 + 18) % 26 = 19`. In this case, the decryption can be performed by replacing each letter in ciphertext with the letter which is to the left by 18 positions:
```
TGG KUSJWV QGM
T = 19
(19 - 18) % 26 = 1 | B
G = 6
(6 - 18) % 26 = 14 | O
(note: after 'shifting', letter position equals -12 which is out of range in alphabet,
performing mod 26 letter position becomes one of the number from 0 to 25, in this case 14)
. . .
```
## Flag
The flag is `flag{BOO SCARED YOU}`