Caesar Cipher Online - Encode and Decode
The Caesar cipher (also known as the shift cipher) is one of the oldest and simplest ciphers, in which the letters in a text are shifted by a certain number of places in the alphabet. The cipher is named after Julius Caesar, who, according to legend, used it to encrypt his military messages.
Enter any text below, select a key, and read the encrypted string using the Caesar cipher.
What is Caesar's Cipher?
Caesar's Cipher is named after one of the most famous Roman figures, Julius Caesar. It is one of the oldest and simplest ways to encrypt text. Other names for this technique are: sliding cipher, Caesar code, Caesarian shift.
Caesar's cipher is very simple to use, but also very easy to break, since there are only 26 different possible letter offsets. To break Caesar's cipher, all you have to do is try all 26 possible offsets and see which one yields a meaningful text. Therefore, nowadays the Caesar cipher is no longer used to encode important information, but is often used as an example of a simple cipher in learning cryptography.
How does encryption with the Caesar cipher work?
The mechanism used on this site uses the following list of letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
- there are exactly 26 characters.
Any character not in this list (including spaces and numbers) is left unchanged.
To start encrypting (shifting) the letters, you must first choose a key, which is the integer by which you will shift the letters. Julius Caesar used a key whose value was 3, and for the sake of this example we will use this key as well.
Once we have determined the key, we can determine a second string (based on the alphabet) in which the letters are shifted by a certain number of positions relative to the first string. For our string, the shifted string will look like this DEFGHIJKLMNOPQRSTUVWXYZABC
Suppose we want to encrypt the text SUPER SECRET MESSAGE
(with key 3). We have the following two strings: Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Ciphertext: DEFGHIJKLMNOPQRSTUVWXYZABC Based on this, we replace each letter in the sentence to be encrypted. The letter S corresponds to the letter V, we replace U with X, and so on. In this way, after the substitution, the text looks like this: VXSHU VHFUHW PHVVDJH
Decrypting a text encrypted with the Caesar cipher
Deciphering a text previously encrypted with the Caesar cipher is a reverse operation. We can invert the two strings we created before, or we can create a new string that is a cipher. For this new string, however, the letters must be shifted in the opposite direction.
A mathematical approach
Caesar's cipher can be described in mathematical terms. Assign a number to each letter of the alphabet: A = 0, B = 1, C = 2, ..., Z = 25. The key k is a number between 0 and 25. The encryption can then be defined by the following formula C = (x + k) mod 25
where x is the number of the letter to be encrypted.
The decryption is then written asD = (x - k) mod 25
Caesar Cipher Online - Encode and Decode
At the top of the page there are two fields where you can enter text. Note that one of them is always inactive. In the middle there is an option to choose the action you want to perform: encryption or decryption, a choice of key (offset) and a button to delete the entered text.
Conclusion
Although the Caesar cipher is no longer used for serious information encryption, its history is interesting and worth learning. The Caesar cipher was one of the first ciphers known to mankind and was used for many centuries to encode various messages. It was widely used because of its simplicity and ease of implementation.