Set the Caesar cipher tool to a shift of 25, type “abc”, and the output is “zab”. Every letter steps back one place, and A wraps round to Z. That wrap looks like the heart of the cipher, yet no Roman source describes it. No ciphered letter of Caesar's is known to survive, and the earliest surviving account of his method is a single sentence by Suetonius, written about a century and a half after his death.

The mod-26 formula, the wrap-around and ROT13 all came long after Caesar; the Latin sources show how far the modern version has drifted from what Romans actually described.

Decoding a message when nobody tells you the shift

In 1883 Auguste Kerckhoffs published “La cryptographie militaire” in two parts of the Journal des sciences militaires. One of his requirements for a field cipher is that the system must not depend on being kept secret: it should be able to fall into enemy hands without harming its users. In modern terms, everything except the key may be public. Everyone knows how a Caesar shift works, so the whole secret is one number from 0 to 25.

With a key that small, an attacker simply tries every value. The tool's All 26 shifts grid does exactly that, listing the input under every key at once. A shifted English sentence shows up as one readable row among 25 rows of nonsense.

In Decode mode each row decodes instead of encoding: row n shows the text decoded with shift n, so the plaintext appears in the row matching the shift originally used.

Claude Shannon's 1949 paper, “Communication Theory of Secrecy Systems”, gives the vocabulary for why this is so easy:

  • The key space is the set of keys an attacker has to consider. Here it has 26 entries.
  • Equivocation measures how uncertain the attacker still is about the key after seeing the ciphertext.
  • The unicity distance is roughly how much ciphertext is needed before only one key produces a meaningful message.

A tiny key space combined with a highly redundant language like English makes the unicity distance very short. Applying Shannon's formula, the unicity distance of a simple shift comes out at only a letter or two of English. In practice the grid shows a little more ambiguity than the theory. One very short word can leave two or three rows that look like words, and a sentence of a few words usually leaves only one.

At the opposite extreme, Shannon showed that the one-time pad is perfectly secret: with a truly random key as long as the message and never reused, the ciphertext tells an attacker nothing about the plaintext.

What a shift leaves in plain sight

Even before anyone tries a key, a shift gives a lot away. Word lengths, spaces, punctuation, capital letters and digits all pass through unchanged. At shift 13, “abc 123 xyz” becomes “nop 123 klm”: the numbers sit in plain view and the three-letter word structure is intact.

Those patterns are strong hints. A one-letter word is almost certainly “a” or “I”, and a single letter after an apostrophe is usually “s” or “t”. A reader can often guess the shift from them alone.

The more general attack is frequency analysis. Its earliest known description comes from the 9th-century scholar al-Kindi, as surveyed by al-Kadi in Cryptologia. It works because a substitution keeps each letter's frequency and only moves it to a different symbol, so it defeats any cipher that uses one substitution alphabet, not only shifts. The guide to the Caesar cipher and ROT13 shows how candidate shifts are scored against English letter frequencies.

This tool also leaks in a way specific to its alphabet. It rotates only the ASCII ranges A–Z and a–z and copies every other character unchanged. Polish and accented letters such as ą, ę, ł, é and ü, other scripts and emoji are not rotated, and they are not included in the Letters shifted count. The count is 6 for “abc 123 xyz” and 10 for “Hello, World!”. A shifted Polish sentence therefore keeps its diacritics, which reveals both the language and many word shapes.

Testing the mod-26 story against the Latin

Modern descriptions present Caesar's cipher as a rotation of a 26-letter alphabet. The ancient texts are much thinner than that.

Caesar: the fourth letter for the first

In chapter 56 of his Life of Julius Caesar, Suetonius lists Caesar's surviving writings, including letters to Cicero and to close friends. In the 1913 Loeb translation, Caesar, “if he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out.” Suetonius then gives the key: to read such a letter, substitute the fourth letter of the alphabet, D, for A, and so on with the others.

That is the whole of Suetonius's description. It says that letters were replaced, that the offset was three positions, and that the rest of the alphabet followed the same rule. It says nothing about the end of the alphabet, about how often Caesar used the method, or about whether he ever changed the offset.

Cassius Dio, writing in the early 3rd century, gives the same rule in his Roman History (40.9.3): in secret messages Caesar wrote, in place of each letter, the fourth letter along. He adds nothing about the end of the alphabet either.

Aulus Gellius, writing in the 2nd century, confirms that the practice was known. In Attic Nights 17.9 he describes collections of Caesar's letters to Gaius Oppius and Cornelius Balbus in which single letters appear without forming syllables, and mentions that the grammarian Probus wrote a fairly careful commentary on the secret meaning of the letters in Caesar's correspondence. Gellius explains only that one letter stood in for another by prior agreement; he gives no offset, and Probus's commentary is lost.

Augustus: B for A, and AA for X

Suetonius also describes the scheme used by Caesar's adopted heir. In Augustus 88 the Latin text reads: “Quotiens autem per notas scribit, B pro A, C pro B ac deinceps eadem ratione sequentis litteras ponit; pro X autem duplex A.” When Augustus wrote in cipher, he replaced each letter with the next one, and for X he wrote a double A.

So Augustus did not wrap around. At X he did not continue from A but wrote a doubled letter instead: a shift of one with a special case, not a clean rotation. The passage suggests that, for this purpose, his alphabet ended at X; Y and Z were recent borrowings from Greek.

Translators have adjusted the passage too. The older Thomson/Forester translation on Perseus, which numbers it chapter 86, ends with “instead of z, aa”, using a letter the Latin does not mention.

Scheme Attested rule End of the alphabet
Caesar (Suetonius, Julius 56; Dio 40.9.3) D for A, and so on: a shift of 3 Not described
Augustus (Suetonius, Augustus 88) B for A, C for B: a shift of 1 AA for X, no wrap
Modern textbook version (x + n) mod 26 Z wraps to A

The Latin alphabet of the time also had no J, U or W, so neither man was working with today's 26 letters. Popular accounts often merge Caesar's and Augustus's schemes. “Mod 26” is a modern idealisation.

Turning one shift into its inverse

The modern version numbers the letters A = 0, B = 1 and so on up to Z = 25, and treats the alphabet as a circle:

encrypt:  E(x) = (x + n) mod 26
decrypt:  D(x) = (x - n) mod 26  =  (x + (26 - n)) mod 26

Subtracting n is the same as adding 26 − n, so decoding is just encoding with the complementary shift. The hint under the tool's slider says so: “13 is ROT13, which decodes itself. To decode a shift of n, use 26 − n.”

On the circle, a step back of one (−1) and a step forward of 25 land on the same letter, which is why the opening example uses 25: the Shift (0–25) slider covers the circle once, and every backward shift has a forward equivalent in that range. A shift of 26, like a shift of 0, is the identity. Some results from the tool:

Input Setting Output
abcXYZ shift 3 defABC
def decode, shift 3 abc
abc shift 25 zab

The first row wraps from Z back to A and keeps upper and lower case separate. The second and third rows are the same idea seen from two sides: decoding by 3 is encoding by 23, and encoding by 25 is a step back of one.

Shifts also compose. A shift of 3 followed by a shift of 10 is a shift of 13, because (x + 3 + 10) mod 26 = (x + 13) mod 26. Encrypting twice adds no strength; it only lands on another of the same 26 keys.

That fixes the key size. There are 26 possible shifts, and one of them (0) does nothing, which leaves 25 useful keys. Since log2(26) is about 4.7, a Caesar key carries at most about 4.7 bits. A random four-digit PIN already has more than 13 bits. For what a “bit” of key or password strength means, see the article on password entropy and where randomness comes from.

Hiding a spoiler with ROT13

Applying a shift twice moves each letter by 2n. That returns the original text only when 2n is a multiple of 26, and among the shifts 1 to 25 only 13 qualifies. ROT13 is therefore its own inverse, an involution: one operation both encodes and decodes.

The tool's examples show this directly. With the slider at 13, the Decode ROT13 example loads “Uryyb, Jbeyq!” and the output reads “Hello, World!”; feeding “Hello, World!” back in at shift 13 gives “Uryyb, Jbeyq!” again. The example buttons only fill in the text, so at any other shift the output will differ.

That property explains its popularity on Usenet. Both the Jargon File and the ROT13 encyclopedia entry describe it as the convention for hiding spoilers, punchlines and jokes that some readers might find offensive. The point was never secrecy. The reader had to choose to reveal the text, so nobody saw it by accident, and since one operation works both ways, nobody needed a separate decoder.

On Unix-like systems the same rotation is commonly written as a single tr command:

tr 'A-Za-z' 'N-ZA-Mn-za-m'

The POSIX specification of tr describes range notation such as a-z; in the POSIX (C) locale, ranges follow the character order, while in other locales range behaviour is left unspecified. The command maps the first set onto the second, position by position, so A becomes N, M becomes Z and N becomes A, and the lower-case ranges follow the same pattern. ROT13 is not one of the standard's own examples, just a natural use of range mapping.

When one shift is not enough

The obvious way to strengthen a Caesar shift is to stop using just one. A Vigenère cipher is a series of Caesar shifts chosen by the letters of a keyword. The first letter of the message is shifted by the first keyword letter, the second by the second, and so on, with the keyword repeating. Because the shift changes from position to position, the frequency pattern of a single shift is smeared out, and trying all 26 keys no longer works.

In the other direction, the Caesar shift is the simplest case of the affine cipher, (a·x + b) mod 26: with a = 1, it reduces to a Caesar shift with key b. The larger family of keys still produces a single substitution alphabet, so frequency analysis still applies.

A cipher disk is the same arithmetic in physical form: two concentric rings of letters, turned against each other to set the shift. Turning the ring to a new setting for each letter, following an agreed keyword, turns the disk into a Vigenère cipher.

Privacy

The Caesar cipher tool runs entirely in your browser and makes no network requests with your text. The page shows the badge “Runs locally in your browser”. Nothing you type is uploaded or stored.

Local processing protects your input from the network. It does not make the output secret. Anyone who sees a shifted text can reverse it in seconds, so use a shift for puzzles, spoilers and teaching, never for passwords or personal data.

FAQ

Does applying ROT13 twice make a message more secure?

No. ROT13 is its own inverse, so applying it twice returns the original text. Stacking other shifts does not help either; as the section on inverting a shift explains, any two shifts add up to one shift from the same 26.

Did Caesar's cipher wrap around from the end of the alphabet back to the start?

The sources do not say. Suetonius and Cassius Dio give only the rule of the fourth letter for the first, D for A. The one ancient description of what happened at the end of the alphabet concerns Augustus, who wrote AA for X instead of wrapping. The wrap-around version is a modern convention.

How much key strength does a Caesar shift actually have, in bits?

At most about 4.7 bits, since log2(26) ≈ 4.7, and one of those 26 keys (shift 0) leaves the text unchanged. In practice the strength is close to zero, because a reader can check every key at a glance.

Why are Polish letters such as ą and ł left unchanged by the shift?

This tool rotates only the 26 letters of the basic Latin alphabet, in upper and lower case. Letters outside that set, including ą, ę, ł and other letters with diacritics, are copied through unchanged and are not counted as shifted. The tool has no alphabet option for other languages.

Is a Caesar shift the same kind of thing as converting text to binary?

Not quite. Converting text to binary is an encoding: a public mapping with no key, which anyone can reverse. A Caesar shift does have a key, but the key is so small that in practice it behaves almost the same way. Reversing text is another reversible transformation that hides nothing.

Further reading