In cryptography, a **Caesar cipher**, also known as **Caesarâ€™s cipher**, the **shift cipher**, **Caesarâ€™s code** or **Caesar shift**, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.

The transformation can be represented by aligning two alphabets; the cipher alphabet is the plain alphabet rotated left or right by some number of positions. For instance, here is a Caesar cipher using a left rotation of three places, equivalent to a right shift of 23 (the shift parameter is used as the key):

```
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
```

When encrypting, a person looks up each letter of the message in the â€śplainâ€ť line and writes down the corresponding letter in the â€ścipherâ€ť line.

```
Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD
```

Complexity:

- Time: O(|n|)
- Space: O(|n|)

Polynomial Rolling HashJun 06, 2024

Big-O NotationFeb 06, 2024

Rabinâ€“Karp String SearchingSep 10, 2021

Dynamic Programming (DP)Jan 16, 2022

Competitive Programming TopicsFeb 02, 2022

Bloom FilterFeb 02, 2022

Data Structures Used in Competitive ProgrammingFeb 04, 2022