Recent from talks
Nothing was collected or created yet.
Caesar cipher
View on Wikipedia

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.[1] The method is named after Julius Caesar, who used it in his private correspondence.
The encryption step performed by a Caesar cipher is often incorporated as part of more complex schemes, such as the Vigenère cipher, and still has modern application in the ROT13 system. As with all single-alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communications security.
Example
[edit]The transformation can be represented by aligning two alphabets; the cipher 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 | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cipher | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W |
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
Deciphering is done in reverse, with a right shift of 3.
The encryption can also be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A → 0, B → 1, ..., Z → 25.[2] Encryption of a letter x by a shift n can be described mathematically as,[3][4]
Decryption is performed similarly,
(Here, "mod" refers to the modulo operation. The value x is in the range 0 to 25, but if x + n or x − n are not in this range then 26 should be added or subtracted.)
The replacement remains the same throughout the message, so the cipher is classed as a type of monoalphabetic substitution, as opposed to polyalphabetic substitution.
History and usage
[edit]
The Caesar cipher is named after Julius Caesar, who, according to Suetonius, used it with a shift of three (A becoming D when encrypting, and D becoming A when decrypting) to protect messages of military significance.[5] While Caesar's was the first recorded use of this scheme, other substitution ciphers are known to have been used earlier.[6][7]
"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. If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others."
His nephew, Augustus, also used the cipher, but with a right shift of one, and it did not wrap around to the beginning of the alphabet:
"Whenever he wrote in cipher, he wrote B for A, C for B, and the rest of the letters on the same principle, using AA for Z."
— Suetonius, Life of Augustus 88
Evidence exists that Julius Caesar also used more complicated systems,[8] and one writer, Aulus Gellius, refers to a (now lost) treatise on his ciphers:
"There is even a rather ingeniously written treatise by the grammarian Probus concerning the secret meaning of letters in the composition of Caesar's epistles."
— Aulus Gellius, Attic Nights 17.9.1–5
It is unknown how effective the Caesar cipher was at the time; there is no record at that time of any techniques for the solution of simple substitution ciphers. The earliest surviving records date to the 9th-century works of Al-Kindi in the Arab world with the discovery of frequency analysis.[9]
A piece of text encrypted in a Hebrew version of the Caesar cipher not to be confused with Atbash, is sometimes found on the back of Jewish mezuzah scrolls. When each letter is replaced with the letter before it in the Hebrew alphabet the text translates as "YHWH, our God, YHWH", a quotation from the main part of the scroll.[10][11]
In the 19th century, the personal advertisements section in newspapers would sometimes be used to exchange messages encrypted using simple cipher schemes. David Kahn (1967) describes instances of lovers engaging in secret communications enciphered using the Caesar cipher in The Times.[12] Even as late as 1915, the Caesar cipher was in use: the Russian army employed it as a replacement for more complicated ciphers which had proved to be too difficult for their troops to master; German and Austrian cryptanalysts had little difficulty in decrypting their messages.[13]

Caesar ciphers can be found today in children's toys such as secret decoder rings. A Caesar shift of thirteen is also performed in the ROT13 algorithm, a simple method of obfuscating text widely found on Usenet and used to obscure text (such as joke punchlines and story spoilers), but not seriously used as a method of encryption.[14]
The Vigenère cipher uses a Caesar cipher with a different shift at each position in the text; the value of the shift is defined using a repeating keyword.[15] If the keyword is as long as the message, is chosen at random, never becomes known to anyone else, and is never reused, this is the one-time pad cipher, proven unbreakable. However the problems involved in using a random key as long as the message make the one-time pad difficult to use in practice. Keywords shorter than the message (e.g., "Complete Victory" used by the Confederacy during the American Civil War), introduce a cyclic pattern that might be detected with a statistically advanced version of frequency analysis.[16]
In April 2006, fugitive Mafia boss Bernardo Provenzano was captured in Sicily partly because some of his messages, clumsily written in a variation of the Caesar cipher, were broken. Provenzano's cipher used numbers, so that "A" would be written as "4", "B" as "5", and so on.[17]
In 2011, Rajib Karim was convicted in the United Kingdom of "terrorism offences" after using the Caesar cipher to communicate with Bangladeshi Islamic activists discussing plots to blow up British Airways planes or disrupt their IT networks. Although the parties had access to far better encryption techniques (Karim himself used PGP for data storage on computer disks), they chose to use their own scheme (implemented in Microsoft Excel), rejecting a more sophisticated code program called Mujahedeen Secrets "because 'kaffirs', or non-believers, know about it, so it must be less secure".[18]
Breaking the cipher
[edit]| Decryption shift |
Candidate plaintext |
|---|---|
| 0 | exxegoexsrgi |
| 1 | dwwdfndwrqfh |
| 2 | cvvcemcvqpeg |
| 3 | buubdlbupodf |
| 4 | attackatonce |
| 5 | zsszbjzsnmbd |
| 6 | yrryaiyrmlac |
| ... | |
| 23 | haahjrhavujl |
| 24 | gzzgiqgzutik |
| 25 | fyyfhpfytshj |
The Caesar cipher can be easily broken even in a ciphertext-only scenario. Since there are only a limited number of possible shifts (25 in English), an attacker can mount a brute force attack by deciphering the message, or part of it, using each possible shift. The correct description will be the one which makes sense as English text.[19] An example is shown on the right for the ciphertext "exxegoexsrgi"; the candidate plaintext for shift four "attackatonce" is the only one which makes sense as English text. Another type of brute force attack is to write out the alphabet beneath each letter of the ciphertext, starting at that letter. Again the correct decryption is the one which makes sense as English text. This technique is sometimes known as "completing the plain component".[20][21]

Another approach is to match up the frequency distribution of the letters. By graphing the frequencies of letters in the ciphertext, and by knowing the expected distribution of those letters in the original language of the plaintext, a human can easily spot the value of the shift by looking at the displacement of particular features of the graph. This is known as frequency analysis. For example, in the English language the plaintext frequencies of the letters E, T, (usually most frequent), and Q, Z (typically least frequent) are particularly distinctive.[22] Computers can automate this process by assessing the similarity between the observed frequency distribution and the expected distribution. This can be achieved, for instance, through the utilization of the chi-squared statistic[23] or by minimizing the sum of squared errors between the observed and known language distributions.[24]
The unicity distance for the Caesar cipher is about 2, meaning that on average at least two characters of ciphertext are required to determine the key.[25] In rare cases more text may be needed. For example, the words "river" and "arena" can be converted to each other with a Caesar shift, which means they can produce the same ciphertext with different shifts. However, in practice the key can almost certainly be found with at least 6 characters of ciphertext.[26]
With the Caesar cipher, encrypting a text multiple times provides no additional security. This is because two encryptions of, say, shift A and shift B, will be equivalent to a single encryption with shift A + B. In mathematical terms, the set of encryption operations under each possible key forms a group under composition.[27]
See also
[edit]Notes
[edit]- ^ Smith, James (2021-11-30). "Writing Secret Messages With a Caesar Cipher". Golang Project Structure. Retrieved 2024-10-20.
- ^ Luciano, Dennis; Gordon Prichett (January 1987). "Cryptology: From Caesar Ciphers to Public-Key Cryptosystems". The College Mathematics Journal. 18 (1): 2–17. CiteSeerX 10.1.1.110.6123. doi:10.2307/2686311. JSTOR 2686311.
- ^ Wobst, Reinhard (2001). Cryptology Unlocked. Wiley. p. 19. ISBN 978-0-470-06064-3.
- ^ "Caesar Cipher". Solidify Software. Retrieved 2025-06-21.
- ^ Suetonius. "56.6". Vita Divi Julii (in Latin).
- ^ "Cracking the Code". Central Intelligence Agency. Archived from the original on 26 December 2020. Retrieved 21 February 2017.
- ^ Singh, Simon (2000). The Code Book. Anchor. pp. 289-290. ISBN 0-385-49532-3.
- ^ Reinke, Edgar C. (December 1962). "Classical Cryptography". The Classical Journal. 58 (3): 114.
- ^ Singh, Simon (2000). The Code Book. Anchor. pp. 14–20. ISBN 0-385-49532-3.
- ^ Eisenberg, Ronald L. (2004). Jewish Traditions (1st ed.). Philadelphia: Jewish Publication Society. p. 582. ISBN 9780827610392.
- ^ Sameth, Mark (2020). The Name : a history of the dual-gendered Hebrew name for God. Eugene, Oregon: Wipf & Stock. pp. 5–6. ISBN 9781532693830.
- ^ Kahn, David (1967). The Codebreakers. pp. 775–6. ISBN 978-0-684-83130-5.
- ^ Kahn, David (1967). The Codebreakers. pp. 631–2. ISBN 978-0-684-83130-5.
- ^ Wobst, Reinhard (2001). Cryptology Unlocked. Wiley. p. 20. ISBN 978-0-470-06064-3.
- ^ Kahn, David (1967). The Codebreakers. pp. 148–149. ISBN 978-0-684-83130-5.
- ^ Kahn, David (1967). The Codebreakers. pp. 398–400. ISBN 978-0-684-83130-5.
- ^ Leyden, John (2006-04-19). "Mafia boss undone by clumsy crypto". The Register. Retrieved 2008-06-13.
- ^ "BA jihadist relied on Jesus-era encryption". The Register. 2011-03-22. Retrieved 2011-04-01.
- ^ Beutelspacher, Albrecht (1994). Cryptology. Mathematical Association of America. pp. 8–9. ISBN 0-88385-504-6.
- ^ Leighton, Albert C. (April 1969). "Secret Communication among the Greeks and Romans". Technology and Culture. 10 (2): 139–154. doi:10.2307/3101474. JSTOR 3101474.
- ^ Sinkov, Abraham; Paul L. Irwin (1966). Elementary Cryptanalysis: A Mathematical Approach. Mathematical Association of America. pp. 13–15. ISBN 0-88385-622-0.
- ^ Singh, Simon (2000). The Code Book. Anchor. pp. 72–77. ISBN 0-385-49532-3.
- ^ Savarese, Chris; Brian Hart (2002-07-15). "The Caesar Cipher". Trinity College. Retrieved 2008-07-16.
- ^ Eisele, Robert (2007-05-18). "Caesar Cipher Decryption". Retrieved 2024-04-02.
- ^ Lubbe, Jan C. A. (12 March 1998). Basic Methods of Cryptography. Cambridge University Press. pp. 47–8. ISBN 9780521555593.
- ^ Pardo, José Luis Gómez (19 December 2012). Introduction to Cryptography with Maple. Springer Berlin Heidelberg. p. 5. ISBN 9783642321665.
- ^ Wobst, Reinhard (2001). Cryptology Unlocked. Wiley. p. 31. ISBN 978-0-470-06064-3.
Bibliography
[edit]- Kahn, David (1996). The Codebreakers: The Story of Secret Writing (Revised ed.). New York. ISBN 0-684-83130-9. OCLC 35159231.
{{cite book}}: CS1 maint: location missing publisher (link) - Chris Savarese and Brian Hart, The Caesar Cipher, Trinity College, 1999
Further reading
[edit]- Bauer, Friedrich Ludwig (2000). Decrypted Secrets: Methods and Maxims of Cryptology (2nd and extended ed.). Berlin: Springer. ISBN 3-540-66871-3. OCLC 43063275.
External links
[edit]Caesar cipher
View on GrokipediaFundamentals
Definition
The Caesar cipher is a monoalphabetic substitution cipher that replaces each letter in the plaintext with another letter a fixed number of positions further in the alphabet, using a consistent shift for the entire message.[5][6] This method creates a direct mapping between the original alphabet and a shifted version of itself, preserving the relative order of letters while obscuring the original text.[5] In contrast to general monoalphabetic substitution ciphers, which allow arbitrary rearrangements of the alphabet, the Caesar cipher restricts the transformation to a simple cyclic shift determined by a single parameter, making it a foundational example of symmetric key encryption.[7][5] The key consists of the shift value k, an integer generally ranging from 1 to 25 in a 26-letter alphabet to exclude the trivial no-shift case, with the classical variant employing k=3.[6] It is attributed to Julius Caesar, who used such a shift for securing private messages.[8] The cipher operates on standard alphabets like the Latin (A-Z), typically leaving non-alphabetic characters unchanged and treating the process as case-insensitive in its basic form, though modern adaptations may preserve case.[6][9][10]Mechanics
The Caesar cipher operates by systematically shifting the letters of the plaintext alphabet by a fixed number of positions, known as the key , where . To formalize this, each letter in the plaintext is first mapped to its numerical position , with A (or a) assigned 0, B (or b) assigned 1, up to Z (or z) assigned 25. The corresponding ciphertext letter is then obtained via the encryption formula , where the result determines the shifted position in the alphabet.[11][12] Decryption reverses this process using the formula , which shifts the ciphertext letters back by positions to recover the original plaintext positions. The modular arithmetic operation ensures the shifting wraps around the alphabet cyclically: for instance, shifting Z (25) forward by 1 yields A (0), as , preventing overflow beyond the 26-letter boundary.[11][13] Non-alphabetic characters, such as spaces, punctuation, or numbers, are typically left unchanged during both encryption and decryption to preserve the message's structure.[14] Regarding case sensitivity, implementations often standardize the text to uppercase or lowercase for processing, though some preserve the original case by applying the shift separately to uppercase and lowercase alphabets.[15] A classical example uses , shifting each letter forward by three positions.[12]Historical Context
Origins
The Caesar cipher is attributed to Julius Caesar (100–44 BCE), who employed it to secure confidential communications during his time as a Roman general and statesman. According to the Roman historian Suetonius in his biographical work De Vita Caesarum (The Lives of the Twelve Caesars), completed around 121 CE, Caesar wrote letters to figures like Cicero and his close associates using a substitution method to obscure sensitive content from potential interceptors.[8] Suetonius notes that Caesar shifted each letter in the Latin alphabet by three positions, such that A became D, B became E, and so on, rendering the text unintelligible without the key.[8] Other 2nd-century Roman authors, including Aulus Gellius and Cassius Dio, also described this cipher in their works.[16] This account by Suetonius represents the earliest documented description of the cipher, dating to the early 2nd century CE, though Caesar's usage likely occurred during his military campaigns in the late Roman Republic, particularly the Gallic Wars (58–50 BCE).[16] While ancient civilizations, such as the Hebrews with the Atbash substitution around 600 BCE, developed other forms of letter replacement, no concrete evidence exists for a systematic shift cipher prior to the Roman era.[7] The cipher's invention aligns with the needs of Roman expansion, where secure transmission of orders and intelligence was essential amid frequent interceptions by enemies.[17] In the classical Roman context, the cipher facilitated both military dispatches and political correspondence, protecting strategic information during the turbulent final decades of the Republic.[18] Suetonius emphasizes its application in private letters containing confidential matters, underscoring its role in maintaining secrecy among elites in an era of civil strife and espionage.[8] This early form of encryption thus marked a foundational step in cryptographic practice, tailored to the Latin alphabet and the demands of Roman governance.[19]Usage
Following its initial adoption in ancient Roman military communications, the Caesar cipher saw renewed use in medieval and Renaissance Europe as a straightforward method for secret writing, particularly in diplomatic exchanges to safeguard confidential information from interception. By the late 14th century, European states employed substitution ciphers, including shift-based techniques similar to the Caesar method, for official correspondence amid rising espionage concerns during conflicts and alliances.[20] In Renaissance Venice, such enciphered dispatches were standard by 1411, drawing on classical Roman precedents documented by Suetonius, with professional codebreakers like Giovanni Soro refining these systems for state diplomacy in the early 16th century.[21] The cipher's cultural prominence grew in the 19th century through literary works, most notably Edgar Allan Poe's 1843 short story "The Gold-Bug," which centered on a substitution cipher puzzle solved through frequency analysis, sparking widespread public interest in cryptography as an intellectual pursuit. Poe's narrative, featuring protagonist William Legrand decoding a hidden message to uncover treasure, exemplified the role of substitution ciphers in early detective fiction and popularized code-solving as a recreational challenge.[22] In the modern era, a variant known as ROT13—employing a fixed shift of 13 positions—became prevalent on Usenet newsgroups starting in the early 1980s, primarily to obscure spoilers in discussions of films, books, and events, as well as potentially offensive humor, allowing voluntary decoding by interested readers.[23] This self-inverse transformation, which decodes identically when applied twice, facilitated quick online encoding and remains supported by tools like rot13.com for casual text obfuscation in forums and emails.[24] Outside secure communications, the Caesar cipher serves extensively in non-military domains, including puzzles, board games, and educational curricula designed to build foundational cryptography skills.[25] It appears in activities like code-cracking challenges in science museums and classrooms, where participants shift letters to encode messages and learn about substitution patterns without needing advanced tools.[26] Such applications emphasize conceptual understanding over protection, fostering problem-solving in subjects like computer science and history.[27] Although historically versatile, the Caesar cipher is seldom applied in practice for genuine security, given its susceptibility to basic attacks like exhaustive key testing across only 25 possible shifts, rendering it ineffective against determined adversaries.[28] It endures instead for trivial obfuscation, such as hiding puzzle solutions or temporary text scrambling in low-stakes environments.[29]Practical Illustration
Encryption Example
To illustrate the encryption process of the Caesar cipher, consider the uppercase plaintext "THEQUICKBROWNFOX", the well-known phrase "THE QUICK BROWN FOX" (omitting spaces for clarity), encrypted with the classical shift of k=3 as used by Julius Caesar. Each letter's position in the alphabet (A=0, B=1, ..., Z=25) is increased by 3 modulo 26 to determine the ciphertext letter. The step-by-step transformation begins with T at position 19, yielding (19 + 3) mod 26 = 22, which corresponds to W; H at position 7 becomes (7 + 3) mod 26 = 10 or K; E at 4 becomes 7 or H; Q at 16 becomes 19 or T; U at 20 becomes 23 or X; I at 8 becomes 11 or L; C at 2 becomes 5 or F; K at 10 becomes 13 or N; B at 1 becomes 4 or E; R at 17 becomes 20 or U; O at 14 becomes 17 or R; W at 22 becomes 25 or Z; N at 13 becomes 16 or Q; F at 5 becomes 8 or I; the second O at 14 becomes 17 or R; and X at 23 becomes (23 + 3) mod 26 = 0 or A. The resulting ciphertext is "WKHTXLFNEURZQIRA".Plaintext 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
Ciphertext alphabet: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Plaintext 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
Ciphertext alphabet: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C