✖

Caesar cipher

The Caesar cipher is a very simple cipher that Julius Caesar used in his military communications.

How the encryption works

The cipher can work with any alphabet, but we usually assume that it works with the 26-letter English alphabet ab…yz. The classic Caesar cipher worked like this: each letter of the plaintext was “shifted” three letters further on. So instead of the letter “a” you wrote the letter “d”, instead of the letter “b” you wrote the letter “e”, and so on. When we reach the end of the alphabet, we start again from the beginning — so the letter “z” is encrypted as the letter “c”. The whole shift is shown in the following table:

The first row contains the letters of the plaintext and the second row the letters of the ciphertext. This means that we would encrypt the word “hello” as the text “khoor”.

Generalising the Caesar cipher

Whereas Caesar supposedly always used a shift of exactly three letters, we can generalise the Caesar cipher to a shift by any number of letters. The key of the cipher is then the letter to which the letter “a” is mapped. So the original Caesar cipher is a shift by three letters, which corresponds to the letter “d”, because “a” is mapped to “d”. In the sample tables the key is highlighted in bold. You can also generate a table for any key you like:

Key:

Encryption works the same way: we find the letter in the top row and write the corresponding letter from the bottom row in its place. Decryption goes in the opposite direction — we find the letter in the bottom row and write the letter from the top row in its place.

Example of decryption: we have the ciphertext “haazo” and we want to decrypt it using the key w. We generate a table with the key “w” and find the letters “haazo” in the bottom row. In the top row we read the original text: “leeds”.

Online tool for encrypting and decrypting the Caesar cipher

Finally, you can encrypt and then decrypt any text using any key:

Text:
Key: