Caesar cipher: Difference between revisions
imported>Andpend m add reference example |
imported>JingleJim →Example: diction |
||
| (One intermediate revision by one other user not shown) | |||
| Line 25: | Line 25: | ||
--> | --> | ||
A '''Caesar cipher'''{{efn|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 used in [[cryptography]]. It is a type of [[substitution cipher]] in which each letter in the [[plaintext]] is replaced by a letter some fixed number of positions along the [[alphabet]]. For example, with a left shift of 3, {{mono|D}} would be replaced by {{mono|A}}, {{mono|E}} would become {{mono|B}}, and so on.<ref>{{cite web|first = James|last = Smith|work = Golang Project Structure|title = Writing Secret Messages With a Caesar Cipher|url = https://golangprojectstructure.com/caesar-cipher-secret-messages/|date = 2021-11-30|url-status = live|archive-url = https://web.archive.org/web/20241105025547/https://golangprojectstructure.com/caesar-cipher-secret-messages/|archive-date = 2024-11-05|access-date = 2024-10-20}}</ref> 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]]. | 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]]. | ||
| Line 31: | Line 31: | ||
==Example== | ==Example== | ||
{{Wikifunctions|Z12812|Latin alphabet Caesar cipher}} | {{Wikifunctions|Z12812|Latin alphabet Caesar cipher}} | ||
The transformation can be represented by aligning two alphabets; the cipher is the plain alphabet | The transformation can be represented by aligning two alphabets; the cipher is the plain alphabet shifted left or right by a certain number of positions. For instance, here is a Caesar cipher using a left shift of three places, equivalent to a right shift of 23 (the shift parameter is used as the [[key (cryptography)|key]]): | ||
{{Aligned table|cols=27|class=wikitable|col1header=on | {{Aligned table|cols=27|class=wikitable|col1header=on | ||
| Line 43: | Line 43: | ||
Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD | Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD | ||
Deciphering is done in reverse, with a | Deciphering is done in reverse, with a left 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.<ref>{{cite journal |last=Luciano |first=Dennis |author2=Gordon Prichett |date=January 1987 |title=Cryptology: From Caesar Ciphers to Public-Key Cryptosystems |journal=The College Mathematics Journal |volume=18 |issue=1 |pages=2–17 |doi=10.2307/2686311 |jstor=2686311 |citeseerx=10.1.1.110.6123 }}</ref> Encryption of a letter ''x'' by a shift ''n'' can be described mathematically as | 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.<ref>{{cite journal |last=Luciano |first=Dennis |author2=Gordon Prichett |date=January 1987 |title=Cryptology: From Caesar Ciphers to Public-Key Cryptosystems |journal=The College Mathematics Journal |volume=18 |issue=1 |pages=2–17 |doi=10.2307/2686311 |jstor=2686311 |citeseerx=10.1.1.110.6123 }}</ref> Encryption of a letter ''x'' by a shift ''n'' can be described mathematically as:<ref>{{cite book |title=Cryptology Unlocked |url=https://archive.org/details/Cryptology_Unlocked |last=Wobst |first=Reinhard |year=2001 |publisher=Wiley |isbn=978-0-470-06064-3 |page=19 }}</ref><ref>{{cite web |title=Caesar Cipher |url=https://solidify.software/posts/caesar-cipher |website=Solidify Software |url-status=live |archive-url=https://web.archive.org/web/20250621223017/https://solidify.software/posts/caesar-cipher |archive-date=2025-06-21 |access-date=2025-06-21}}</ref> | ||
: <math>E_n(x) = (x + n) \mod {26}.</math> | : <math>E_n(x) = (x + n) \mod {26}.</math> | ||
Decryption is performed similarly | Decryption is performed similarly: | ||
: <math>D_n(x) = (x - n) \mod {26}.</math> | : <math>D_n(x) = (x - n) \mod {26}.</math> | ||
| Line 59: | Line 59: | ||
==History and usage== | ==History and usage== | ||
{{See also|History of cryptography}} | {{See also|History of cryptography}} | ||
[[File:Bust of Julius Caesar from History of the World (1902).png| | [[File:Bust of Julius Caesar from History of the World (1902).png|thumb|upright=0.7|The Caesar cipher is named for [[Julius Caesar]], who used an alphabet where decrypting would shift three letters to the right.]] | ||
The Caesar cipher is named | The Caesar cipher is named for [[Julius Caesar]], who, according to the Roman historian [[Suetonius]], used it with a shift of three ({{mono|A}} becoming {{mono|D}} when encrypting, and vice versa when decrypting) to protect messages of military significance.<ref name=":0" /><ref>{{cite book |author=Suetonius |author-link= |url=https://www.perseus.tufts.edu/hopper/text?doc=Perseus%3Atext%3A1999.02.0132%3Alife%3Djul.%3Achapter%3D56 |title=The Lives of the Twelve Caesars |chapter=Jul. 56}}</ref> While Caesar's was the first recorded use of this scheme, other substitution ciphers are known to have existed earlier.<ref>{{cite web|title=Cracking the Code|url=https://www.cia.gov/news-information/featured-story-archive/2007-featured-story-archive/cracking-the-code.html|website=Central Intelligence Agency|access-date=21 February 2017|url-status=dead|archive-url=https://web.archive.org/web/20201226065538/https://www.cia.gov/news-information/featured-story-archive/2007-featured-story-archive/cracking-the-code.html|archive-date=26 December 2020}}</ref><ref>{{cite book |title=[[The Code Book]] |last=Singh |first=Simon |author-link=Simon Singh |year=2000 |publisher=Anchor |isbn=0-385-49532-3 |pages=[https://archive.org/details/codebook00simo/page/289 289–290] }}</ref> Suetonius writes that his nephew, [[Augustus]], used the cipher with a right shift of one, but it did not wrap around to the beginning of the [[Latin alphabet]], instead replacing {{mono|Z}} with {{mono|AA}}.<ref name=":0" /><ref>{{Cite book |last=Suetonius |url=http://www.perseus.tufts.edu/hopper/text?doc=Perseus%3Atext%3A1999.02.0132%3Alife%3Daug.%3Achapter%3D86 |title=The Lives of the Twelve Caesars |chapter=Aug. 86}}</ref> Evidence exists that Caesar also used more complicated systems.<ref name=":0">{{cite journal |last=Reinke |first=Edgar C. |date=December 1962 |title=Classical Cryptography |journal=The Classical Journal |volume=58 |issue=3 |page=114 }}</ref> The grammarian [[Aulus Gellius]] refers to a (now lost) treatise on his ciphers:{{Blockquote|"There is even a rather ingeniously written treatise by the grammarian [[Marcus Valerius Probus|Probus]] concerning the secret meaning of letters in the composition of Caesar's epistles."|[[Aulus Gellius]]|''Attic Nights 17.9.1–5''}} | ||
{{ | |||
Evidence exists that | |||
{{Blockquote|"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 | It is unknown how effective the Caesar cipher was at the time: there is no record of contemporary 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#Early history|Arab world]] with the discovery of [[frequency analysis]].<ref>{{cite book |title=[[The Code Book]] |last=Singh |first=Simon |author-link=Simon Singh |year=2000 |publisher=Anchor |isbn=0-385-49532-3 |pages=[https://archive.org/details/codebook00simo/page/14 14–20] }}</ref> | ||
A piece of text encrypted in a [[Hebrew language|Hebrew]] version of the Caesar cipher not to be confused with [[Atbash]] | A piece of text encrypted in a [[Hebrew language|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 reads "[[YHWH]], our God, YHWH", a quotation from the scroll.<ref>{{cite book |last1=Eisenberg |first1=Ronald L. |title=Jewish Traditions |date=2004 |publisher=Jewish Publication Society |location=Philadelphia |isbn=9780827610392 |pages=582 |edition=1st}}</ref><ref>{{cite book |last1=Sameth |first1=Mark |title=The Name : a history of the dual-gendered Hebrew name for God |date=2020 |publisher=Wipf & Stock |location=Eugene, Oregon |isbn=9781532693830 |pages=5–6}}</ref> | ||
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.<ref>{{cite book |last=Kahn |first=David |author-link=David Kahn (writer) |title=The Codebreakers |year=1967 |isbn=978-0-684-83130-5 |pages=148–149}}</ref> Repeating keywords (e.g., "[[Vigenère cipher#History|Complete Victory]]" used by the [[Confederate States of America|Confederacy]] during the [[American Civil War]]) introduce a cyclic pattern that might be detected with statistically advanced frequency analysis.<ref>{{cite book |last=Kahn |first=David |author-link=David Kahn (writer) |title=The Codebreakers |year=1967 |isbn=978-0-684-83130-5 |pages=398–400}}</ref> (''See e.g. [[Coincidence counting]].'') If the keyword is as long as the message, is chosen at [[randomly|random]], never becomes known to anyone else, and is never reused, it is a [[one-time pad]] cipher, impossible to break cryptographically. However, the problems involved in [[Key distribution|distributing]] such a key make the one-time pad difficult to use in practice. | |||
In the 19th century, the [[personal advertisement]]s section in newspapers would sometimes be used to exchange messages encrypted using simple cipher schemes. [[David Kahn (writer)|David Kahn]] (1967) describes instances of lovers engaging in secret communications enciphered using the Caesar cipher in ''[[The Times]]''.<ref>{{cite book |title=The Codebreakers |last=Kahn |first=David |author-link=David Kahn (writer) |year=1967 |isbn=978-0-684-83130-5 |pages=775–6 }}</ref> As late as 1915 during [[World War I]], the Caesar cipher was used by the Russian army as a replacement for more complicated ciphers which had proven difficult for their troops to master; German and Austrian [[Cryptanalysis|cryptanalysts]] had little difficulty in decrypting their messages.<ref>{{cite book |title=The Codebreakers |last=Kahn |first=David |author-link=David Kahn (writer) |year=1967 |isbn=978-0-684-83130-5 |pages=631–2 }}</ref> | |||
In April 2006, fugitive [[Sicilian Mafia|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.<ref>{{cite news |first=John | | [[File:Confederate cipher disk.jpg|alt=Caesar cipher can be constructed into a disk with outer rotating wheel as plain text and the inner fixed wheel as cipher text. Both outer and inner plates should have alphabets in the same direction.|thumb|upright=0.7|Caesar cipher translated to a disk has both outer and inner plates having alphabets in the same direction and not the reverse as seen in CipherDisk2000.]] | ||
In April 2006, fugitive [[Sicilian Mafia|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.<ref>{{cite news |last=Leyden |first=John |date=2006-04-19 |title=Mafia boss undone by clumsy crypto |url=https://www.theregister.co.uk/2006/04/19/mafia_don_clueless_crypto/ |access-date=2008-06-13 |work=[[The Register]]}}</ref> | |||
In 2011, Rajib Karim was convicted | In 2011, [[British Airways]] employee Rajib Karim was convicted of "terrorism offences" after using a Caesar cipher to discuss with Bangladeshi [[Jihadism|jihadi]] activists plots to bomb the airline's planes or disrupt its IT systems. Although the parties had access to far better encryption techniques (Karim himself used [[Pretty Good Privacy|PGP]] for data storage), they chose to use their own scheme implemented in [[Microsoft Excel]], rejecting a more sophisticated code program called [[Mujahedeen Secrets]] "because '[[Kafir|kaffirs]]', or non-believers, know about it, so it must be less secure".<ref>{{cite news |date=2011-03-22 |title=BA jihadist relied on Jesus-era encryption |url=https://www.theregister.co.uk/2011/03/22/ba_jihadist_trial_sentencing/ |access-date=2011-04-01 |work=[[The Register]]}}</ref> | ||
Caesar ciphers can be found today in children's toys such as [[secret decoder ring]]s. A Caesar shift of thirteen is also performed in the [[ROT13]] cipher, a simple method of obfuscating text widely found on [[Usenet]] and used to obscure text (such as joke punchlines and story [[Spoiler (media)|spoilers]]), but not seriously used as a method of encryption.<ref>{{cite book |title=Cryptology Unlocked |url=https://archive.org/details/Cryptology_Unlocked |last=Wobst |first=Reinhard |year=2001 |publisher=Wiley |isbn=978-0-470-06064-3 |page=20 }}</ref> | |||
==Breaking the cipher== | ==Breaking the cipher== | ||
| Line 118: | Line 114: | ||
| {{mono|fyyfhpfytshj}} | | {{mono|fyyfhpfytshj}} | ||
|} | |} | ||
The Caesar cipher can be easily broken even in a [[ciphertext-only attack|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 | The Caesar cipher can be easily broken even in a [[ciphertext-only attack|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 decryption will be the one which makes sense in the language of the plaintext.<ref>{{cite book |title=Cryptology |last=Beutelspacher |first=Albrecht |author-link=Albrecht Beutelspacher |year=1994 |publisher=[[Mathematical Association of America]] |isbn=0-88385-504-6 |pages=8–9 }}</ref> An example is shown on the right for the ciphertext "{{mono|exxegoexsrgi}}"; the candidate plaintext for shift four, "{{mono|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".<ref>{{cite journal |last=Leighton |first=Albert C. |date=April 1969 |title=Secret Communication among the Greeks and Romans |journal=Technology and Culture |volume=10 |issue=2 |pages=139–154 |doi=10.2307/3101474 |jstor=3101474 }}</ref><ref>{{cite book |title=Elementary Cryptanalysis: A Mathematical Approach |last=Sinkov |first=Abraham |author-link=Abraham Sinkov |author2=Paul L. Irwin |year=1966 |publisher=Mathematical Association of America |isbn=0-88385-622-0 |pages=13–15 }}</ref> | ||
[[File:English letter frequency percentages.png|alt=|left|thumb|The distribution of letters in a typical sample of English language text has a distinctive and predictable shape. A Caesar shift "rotates" this distribution, and it is possible to determine the shift by examining the resultant frequency graph.]] | [[File:English letter frequency percentages.png|alt=|left|thumb|The distribution of letters in a typical sample of English language text has a distinctive and predictable shape. A Caesar shift "rotates" this distribution, and it is possible to determine the shift by examining the resultant frequency graph.]] | ||
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 {{mono|E}}, {{mono|T}}, (usually most frequent), and {{mono|Q}}, {{mono|Z}} (typically least frequent) are particularly distinctive.<ref>{{cite book |title=The Code Book |last=Singh |first=Simon |author-link=Simon Singh |year=2000 |publisher=Anchor |isbn=0-385-49532-3 |pages=[https://archive.org/details/codebook00simo/page/72 72–77] |url=https://archive.org/details/codebook00simo/page/72 }}</ref> 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]]<ref>{{cite web |url=http://www.cs.trincoll.edu/~crypto/historical/caesar.html |title=The Caesar Cipher |access-date=2008-07-16 |last=Savarese |first=Chris |author2=Brian Hart |date=2002-07-15 |publisher=[[Trinity College (Connecticut)|Trinity College]] }}</ref> or by minimizing the sum of squared errors between the observed and known language distributions.<ref>{{cite web |url=https://raw.org/tool/caesar-cipher/ |title=Caesar Cipher Decryption |access-date=2024-04-02 |last=Eisele |first=Robert |date=2007-05-18 }}</ref> | 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 {{mono|E}}, {{mono|T}}, (usually most frequent), and {{mono|Q}}, {{mono|Z}} (typically least frequent) are particularly distinctive.<ref>{{cite book |title=The Code Book |last=Singh |first=Simon |author-link=Simon Singh |year=2000 |publisher=Anchor |isbn=0-385-49532-3 |pages=[https://archive.org/details/codebook00simo/page/72 72–77] |url=https://archive.org/details/codebook00simo/page/72 }}</ref> 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]]<ref>{{cite web |url=http://www.cs.trincoll.edu/~crypto/historical/caesar.html |title=The Caesar Cipher |access-date=2008-07-16 |last=Savarese |first=Chris |author2=Brian Hart |date=2002-07-15 |publisher=[[Trinity College (Connecticut)|Trinity College]]|url-status=live|archive-url=https://web.archive.org/web/20110813232738/http://www.cs.trincoll.edu/~crypto/historical/caesar.html|archive-date=2011-08-13 }}</ref> or by minimizing the sum of squared errors between the observed and known language distributions.<ref>{{cite web |url=https://raw.org/tool/caesar-cipher/ |title=Caesar Cipher Decryption |access-date=2024-04-02 |last=Eisele |first=Robert |date=2007-05-18 |url-status=live |archive-url=https://web.archive.org/web/20240324224211/https://raw.org/tool/caesar-cipher/ |archive-date=2024-03-24 }}</ref> | ||
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.<ref>{{cite book |last1=Lubbe |first1=Jan C. A. |title=Basic Methods of Cryptography |date=12 March 1998 |publisher=Cambridge University Press |isbn=9780521555593 |pages=47–8}}</ref> In rare cases more text may be needed. For example, the words "{{mono|river}}" and "{{mono|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.<ref>{{cite book |last1=Pardo |first1=José Luis Gómez |title=Introduction to Cryptography with Maple |date=19 December 2012 |publisher=Springer Berlin Heidelberg |isbn=9783642321665 |page=5}}</ref> | 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.<ref>{{cite book |last1=Lubbe |first1=Jan C. A. |title=Basic Methods of Cryptography |date=12 March 1998 |publisher=Cambridge University Press |isbn=9780521555593 |pages=47–8}}</ref> In rare cases more text may be needed. For example, the words "{{mono|river}}" and "{{mono|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.<ref>{{cite book |last1=Pardo |first1=José Luis Gómez |title=Introduction to Cryptography with Maple |date=19 December 2012 |publisher=Springer Berlin Heidelberg |isbn=9783642321665 |page=5}}</ref> | ||
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'' | 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 {{nowrap|''A'' + ''B''}}. In mathematical terms, the set of encryption operations under each possible key forms a [[group (mathematics)|group]] under [[Function composition|composition]].<ref>{{cite book |title=Cryptology Unlocked |url=https://archive.org/details/Cryptology_Unlocked |last=Wobst |first=Reinhard |year=2001 |publisher=Wiley |isbn=978-0-470-06064-3 |page=31}}</ref> | ||
{{clear left}} | {{clear left}} | ||
==See also== | ==See also== | ||
* | * {{Annotated link|Scytale}} | ||
{{clear}} | {{clear}} | ||
==Notes== | == Notes == | ||
{{notelist}} | |||
==References== | |||
{{reflist}} | {{reflist}} | ||
| Line 140: | Line 139: | ||
==Further reading== | ==Further reading== | ||
* {{Cite book |last=Bauer |first=Friedrich Ludwig | * {{Cite book |last=Bauer |first=Friedrich Ludwig |title=Decrypted Secrets: Methods and Maxims of Cryptology |date=2000 |publisher=Springer |isbn=3-540-66871-3 |edition=2nd and extended |location=Berlin |oclc=43063275|ref=none}} | ||
==External links== | ==External links== | ||
{{commons category|Caesar ciphers}} | {{commons category|Caesar ciphers}} | ||
* {{MathWorld | urlname=CaesarsMethod | title=Caesar's Method |ref=none}} | * {{MathWorld | urlname=CaesarsMethod | title=Caesar's Method |ref=none}} | ||
* [https:// | * [https://cryptii.com/pipes/caesar-cipher Caesar cipher encoder] on Cryptii | ||
{{Cryptography navbox | classical|state=collapsed}} | {{Cryptography navbox | classical|state=collapsed}} | ||
Latest revision as of 12:21, 20 December 2025
Template:Short description Template:Top icon
A Caesar cipherTemplate:Efn is one of the simplest and most widely known encryption techniques used in cryptography. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions along the alphabet. For example, with a left shift of 3, <templatestyles src="Mono/styles.css" />D would be replaced by <templatestyles src="Mono/styles.css" />A, <templatestyles src="Mono/styles.css" />E would become <templatestyles src="Mono/styles.css" />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
Template:Wikifunctions The transformation can be represented by aligning two alphabets; the cipher is the plain alphabet shifted left or right by a certain number of positions. For instance, here is a Caesar cipher using a left shift of three places, equivalent to a right shift of 23 (the shift parameter is used as the key):
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 left 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
Script error: No such module "Labelled list hatnote".
The Caesar cipher is named for Julius Caesar, who, according to the Roman historian Suetonius, used it with a shift of three (<templatestyles src="Mono/styles.css" />A becoming <templatestyles src="Mono/styles.css" />D when encrypting, and vice versa when decrypting) to protect messages of military significance.[5][6] While Caesar's was the first recorded use of this scheme, other substitution ciphers are known to have existed earlier.[7][8] Suetonius writes that his nephew, Augustus, used the cipher with a right shift of one, but it did not wrap around to the beginning of the Latin alphabet, instead replacing <templatestyles src="Mono/styles.css" />Z with <templatestyles src="Mono/styles.css" />AA.[5][9] Evidence exists that Caesar also used more complicated systems.[5] The grammarian Aulus Gellius refers to a (now lost) treatise on his ciphers:<templatestyles src="Template:Blockquote/styles.css" />
"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."
Script error: No such module "Check for unknown parameters".
It is unknown how effective the Caesar cipher was at the time: there is no record of contemporary 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.[10]
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 reads "YHWH, our God, YHWH", a quotation from the scroll.[11][12]
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.[13] Repeating keywords (e.g., "Complete Victory" used by the Confederacy during the American Civil War) introduce a cyclic pattern that might be detected with statistically advanced frequency analysis.[14] (See e.g. Coincidence counting.) If the keyword is as long as the message, is chosen at random, never becomes known to anyone else, and is never reused, it is a one-time pad cipher, impossible to break cryptographically. However, the problems involved in distributing such a key make the one-time pad difficult to use in practice.
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.[15] As late as 1915 during World War I, the Caesar cipher was used by the Russian army as a replacement for more complicated ciphers which had proven difficult for their troops to master; German and Austrian cryptanalysts had little difficulty in decrypting their messages.[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, British Airways employee Rajib Karim was convicted of "terrorism offences" after using a Caesar cipher to discuss with Bangladeshi jihadi activists plots to bomb the airline's planes or disrupt its IT systems. Although the parties had access to far better encryption techniques (Karim himself used PGP for data storage), 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]
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 cipher, 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.[19]
Breaking the cipher
| Decryption shift |
Candidate plaintext |
|---|---|
| 0 | <templatestyles src="Mono/styles.css" />exxegoexsrgi |
| 1 | <templatestyles src="Mono/styles.css" />dwwdfndwrqfh |
| 2 | <templatestyles src="Mono/styles.css" />cvvcemcvqpeg |
| 3 | <templatestyles src="Mono/styles.css" />buubdlbupodf |
| 4 | <templatestyles src="Mono/styles.css" />attackatonce |
| 5 | <templatestyles src="Mono/styles.css" />zsszbjzsnmbd |
| 6 | <templatestyles src="Mono/styles.css" />yrryaiyrmlac |
| ... | |
| 23 | <templatestyles src="Mono/styles.css" />haahjrhavujl |
| 24 | <templatestyles src="Mono/styles.css" />gzzgiqgzutik |
| 25 | <templatestyles src="Mono/styles.css" />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 decryption will be the one which makes sense in the language of the plaintext.[20] An example is shown on the right for the ciphertext "<templatestyles src="Mono/styles.css" />exxegoexsrgi"; the candidate plaintext for shift four, "<templatestyles src="Mono/styles.css" />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".[21][22]
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 <templatestyles src="Mono/styles.css" />E, <templatestyles src="Mono/styles.css" />T, (usually most frequent), and <templatestyles src="Mono/styles.css" />Q, <templatestyles src="Mono/styles.css" />Z (typically least frequent) are particularly distinctive.[23] 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[24] or by minimizing the sum of squared errors between the observed and known language distributions.[25]
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.[26] In rare cases more text may be needed. For example, the words "<templatestyles src="Mono/styles.css" />river" and "<templatestyles src="Mono/styles.css" />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.[27]
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.[28]
See also
Notes
References
<templatestyles src="Reflist/styles.css" />
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ a b c Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
Script error: No such module "Check for unknown parameters".
Bibliography
- Script error: No such module "citation/CS1".
- Chris Savarese and Brian Hart, The Caesar Cipher, Trinity College, 1999
Further reading
- Script error: No such module "citation/CS1".
External links
- Script error: No such module "Template wrapper".
- Caesar cipher encoder on Cryptii
Script error: No such module "Navbox".