Skip to main content

Section 1.1 Simple Early Ciphers (and a little math)

Definition 1.1.1. Cipher.

A cipher is a system by which a letter or block of letters in a message is replaced by another letter or block of letters in a systematic way. In this chapter we will focus on monoalphabetic substitution ciphers in which the substitution is always carried out in the same way with one-to-one correspondence between letters.

One of the earliest types of cipher (sometimes spelled cypher in older documents) that we have a record of was the Caesar shift cipher used by Julius Caesar around 100 BCE. Here it is as described by Suetonius who lived about 150 to 200 years after Julius Caesar.

“There are extant likewise some letters from him to Cicero and others to his friends concerning his domestic affairs in which if there was occasion for secrecy he wrote in cyphers, that is he used the alphabet in such a manner that not a single ward could be made out. The way to decipher those epistles was to substitute the fourth for the first letter as d for a and so for the other letters respectively.” [15, p. 37]

Augustus Caesar a short time later also employed a shift cipher, though arguably a much less effective one:

“When he had occasion to write in cypher he put b for a, c for b [and] so forth and instead of z, aa.” [15, p. 134]

Comprehension Check:

  • In Julius Caesar's cipher what letter was substituted for a? What about in Augustus' cipher, what letter was substituted for a?
  • In Julius Caesar's cipher what letters would replace b, c, and d? What letter should replace n?
  • In Julius Caesar's cipher how would you need to handle the letters x, y, and z?
  • For each plaintext letter write in the corresponding CIPHERTEXT letter using Julius Caesar's cipher system. (We will generally follow the convention that plaintext is lowercase and ciphertext will be uppercase.)
Table 1.1.2. Monoalphabetic Substitution Table
plain a b c d e f g h i
CIPHER
plain j k l m n o p q r
CIPHER
plain s t u v w x y z
CIPHER

Now use the table you filled in to check you understanding.

Use your table to convert this to CIPHERTEXT: “hello world”

Answer

KHOOR ZRUOG

Use your table to convert this to plaintext: WKLV LV D WHVW

Answer

this is a test

Use your table to convert this to plaintext: CRPELHV OLNH CHEUDV

Answer

zombies like zebras

Both of the ciphers described above are called shift ciphers because of how they move letters along in the alphabet, but do not change their order.

Try to figure out the message in the passage below which has been enciphered using a different shift.

Cipher Text:

OLYL PZ H SVUNLY TLZZHNL MVY FVB AV WYHJAPJL VU.
AOL ZOPMA MVY AOPZ TLZZHNL DHZ IF H MHJAVY VM
ZLCLU, ZV AOL H NVLZ AV AOL O.  AOPZ KVLZU'A
YLHSSF VMMLY TBJO TVYL ZLJBYPAF, LZWLJPHSSF ZPUJL
AOLYL HYL VUSF ADLUAF ZPE WVZZPISL ZOPMA JPWOLYZ
HUK VUL VM AOVZL KVLZU'A JOHUNL HUFAOPUN.  DOPSL
FVB DLYL KLJPWOLYPUN AOPZ DOHA WHAALYUZ KPK FVB
UVAPJL? DOHA DVYKZ ZAVVK VBA?  OVD JVBSK DL THRL
AOPZ H TVYL ZLJBYL (OHYKLY AV JYHJR) JPWOLY?
AOLZL HYL HSS XBLZAPVUZ AOHA DL DPSS PUCLZAPNHAL
PU TVYL KLAHPS AOYVBNOVBA AOL ALEA.
Hint
  • Which letters stand alone, i.e. are there one letter words? Can this tell you something about which letters they represent?
  • What about two or three letter words? What might they be?
  • Do some of the letters appear more often than others?
  • Can you think of other properties of words and letters that could help us understand what a message says?
Answer

Here is a longer message for you to practice on. The shift for this message was by a factor of seven, so the a goes to the h. This doesn't really offer much more security, especially since there are only twenty six possible shift ciphers and one of those doesn't change anything. While you were deciphering this what patterns did you notice? What words stood out? How could we make this a more secure (harder to crack) cipher? These are all questions that we will investigate in more detail throughout the text.

Were you able to decrypt the message? Throughout this text we will present material through increasingly more difficult ciphers and codes. Now, take some time to try and hone your skills on the next few passages that demonstrate ways in which ciphers may be made more secure. As you go through each be sure to consider the following questions:

  • How does the new method compare to those which we have previously considered, what does it do to make the message more secure?
  • Each time we change the method in which messages are enciphered what doesn't change?
  • Are there any properties that can not change? That is, are there rules about how English is put together that we can make use of?
  • If you have suspicions about what a message, or part of a message, might say how can you use this to help you?
  • What sort of data might we keep track of or how can we organize our thoughts to help us solve these puzzles?

Cipher Text:

IL JVWF UVD AV TLU VM NYVZZLY ISVVK, HUK ALHJO AOLT
OVD AV DHY. HUK FVB, NVVK FLVTHU, DOVZL SPTIZ DLYL
THKL PU LUNSHUK, ZOVD BZ OLYL AOL TLAASL VM FVBY
WHZABYL; SLA BZ ZDLHY AOHA FVB HYL DVYAO FVBY
IYLLKPUN; DOPJO P KVBIA UVA; MVY AOLYL PZ UVUL VM
FVB ZV TLHU HUK IHZL, AOHA OHAO UVA UVISL SBZAYL
PU FVBY LFLZ. P ZLL FVB ZAHUK SPRL NYLFOVBUKZ PU
AOL ZSPWZ, ZAYHPUPUN BWVU AOL ZAHYA. AOL NHTL'Z
HMVVA: MVSSVD FVBY ZWPYPA, HUK BWVU AOPZ JOHYNL JYF
'NVK MVY OHYYF, LUNSHUK, HUK ZHPUA NLVYNL! - OLUYF
C, DPSSPHT ZOHRLZWLHYL
Answer

“Be copy now to men of grosser blood, And teach them how to war. And you, good yeoman, Whose limbs were made in England, show us here The mettle of your pasture; let us swear That you are worth your breeding; which I doubt not; For there is none of you so mean and base, That hath not noble lustre in your eyes. I see you stand like greyhounds in the slips, Straining upon the start. The game's afoot: Follow your spirit, and upon this charge Cry 'God for Harry, England, and Saint George!” - Henry V, William Shakespeare

Cipher Text:

BJKJB BJMFU UDKJB BJGFS ITKGW TYMJW XKTWM JYTIF DYMFY
XMJIX MNXGQ TTIBN YMRJX MFQQG JRDGW TYMJW GJMJS JJWXT
ANQJY MNXIF DXMFQ QLJSY QJMNX HTSIN YNTSF SILJS YQJRJ
SNSJS LQFSI STBFG JIXMF QQYMN SPYMJ RXJQA JXFHH ZWXJI
YMJDB JWJST YMJWJ FSIMT QIYMJ NWRFS MTTIX HMJFU BMNQJ
XFSDX UJFPX YMFYK TZLMY BNYMZ XZUTS XFNSY HWNXU NSXIF
DMJSW DAGDB NQQNF RXMFP JXUJF WJ
Hint
  • This is a quote by the same author as the previous cipher.
  • The most common letters in the cipher text are J, M, and X.
Answer

“We few, we happy few, we band of brothers; For he to-day that sheds his blood with me Shall be my brother; be he ne'er so vile, This day shall gentle his condition: And gentlemen in England now a-bed Shall think themselves accursed they were not here, And hold their manhoods cheap whiles any speaks That fought with us upon Saint Crispin's day.” - Henry V, by William Shakespeare

Each of the previous messages used a simple shift cipher of which, in English, there are only twenty five (twenty six if you allow a shift of 0). However if we look at all the possible ways that we can rearrange twenty six letters we really have a lot more options.

  • Assuming 26 letters in the alphabet, how many letters can you use to replace a? (For simplicity assume you could choose to replace a with itself if you were so inclined.)
  • Once you have chosen a letter to use in place of a, how many choices for b?
  • What about c?
  • Going in order how many choices do you have for all the remaining orders?
  • What happens if you multiply all these numbers of options together in order to get the total number of choices?

The number you should have come up with is 403 septillion 291 sextillion 461 quintillion 126 quadrillion 605 trillion 635 billion 584 million, or

\begin{equation*} 403,291,461,126,605,635,584,000,000. \end{equation*}

John Falconer in the seventeenth century described this as follows:

Schottus demonstrates, (though the calculation in his book be not exact) that a thousand million of men in as many years could not write down all those different transpositions of the alphabet, granting every one should complete forty pages a day, and every page contain forty several positions: For if one writer in one day write forty pages, everyone containing forty combinations, 40 multiplied by 40, gives 1,600, the number he completes in one day, which multiplied by 366, the number (and more) of days in a year; a writer in one year shall compass 585,600 distinct rows. Therefore in a thousand million of years he could write

\begin{equation*} 585,600,000,000,000, \end{equation*}

which being multiplied by 1,000,000,000, the number of writers supposed, the product will be

\begin{equation*} 585,600,000,000,000,000,000,000, \end{equation*}

which wants of the number of combinations no less than

\begin{equation*} 348,484,017,332,394,393,600,000. \end{equation*}

[4, pages 5-6]

Comprehension Check:

  • How many lines of cipher alphabets does Falconer say there could be on one page?
  • How many pages a day does one person potentially write?
  • How many men does Falconer suggest could be writing and for how long?
  • Are these people able to in that time write out all the possible cipher alphabets?

Imagine that instead of men writing out the cipher alphabets it was a computer. Suppose that a computer can produce one new cipher alphabet every 0.1 seconds (so 10 alphabets a second), how many seconds would it take for the alphabet to write out all \(403,291,461,126,605,635,584,000,000\) alphabets? How many hours is that? How many years? (Assume, like Falconer, that there are 366 days in a year.)

Answer

40,329,146,112,660,563,558,400,000 seconds, 11,202,540,586,850,156,544,000 hours, or 1,275,334,766,262,540,590 and 10/61 years

Today we would call the huge number we calculated above \(26!\text{,}\) which is read "26 factorial," and certainly takes up a lot less room.

Definition 1.1.10. Factorial.

Given a counting number \(n\) we define \(n\)-factorial as the number of ways in which we can arrange \(n\) objects, we calculate it by taking the product of all the consecutive positive integers from \(n\) down to 1, which we write:

\begin{equation} n!=n(n-1)(n-2)\cdots 2 \cdot 1\tag{1.1.1} \end{equation}

Note that for a variety of reasons \(0!=1\text{.}\)

Use the definition above to calculate 4!, 7!, and 10!.

Answer
  • 4!=24
  • 7!=5040
  • 10!=3628800

We can make a message harder to decipher simply by using a more inventive method of encipherment than just a shift. The last exercise in this section was enciphered with a slightly trickier cipher than the previous ciphers so I put the spaces and punctuation back in. Also, while it is a harder cipher it is not completely random, there is a pattern to how the key was generated; so in the table below the message try filling in the cipher alphabet below the plain alphabet as you work, and see if you can spot a pattern.

Cipher Text:

"EACMPA XMT EADGL Z SFGLD, PAKGLR XMTPQAJC SFZS RGCCGBTJSGAQ
ZLR RAJZXQ OTGSA GKNMQQGEJA SM CMPAQAA ZPA ZFAZR. GC XMT
BMTJR QAA SFAK BJAZPJX, LZSTPZJJX XMT BMTJR RM Z DPAZS RAZJ
SM DAS PGR MC SFAK ETS XMT BZL'S. XMT BZL MLJX QAA MLA SFGLD
BJAZPJX ZLR SFZS GQ XMTP DMZJ. CMPK Z KALSZJ UGQGML MC SFZS
ZLR BJGLD SM GS SFPMTDF SFGBI ZLR SFGL." - IZSFJAAL LMPPGQ
Table 1.1.13. Monoalphabetic Substitution Table
plain a b c d e f g h i
CIPHER
plain j k l m n o p q r
CIPHER
plain s t u v w x y z
CIPHER
Hint
  • What letters are on their own in the cipher? Which letters can be on their own in plain English?
  • The cipher letter A is most common, what does that tell you? Likewise, S is second most common so what might that mean?
  • The word QAA appears twice on its own and once as the end of another word, what three letter plaintext words might look like this?
  • After you have spent some time looking at the message and trying to identify some of the ciphertext start to fill in the copy of substitution table and see if you notice any patterns.
Answer

“Before you begin a thing, remind yourself that difficulties and delays quite impossible to foresee are ahead. If you could see them clearly, naturally you could do a great deal to get rid of them but you can't. You can only see one thing clearly and that is your goal. Form a mental vision of that and cling to it through thick and thin.'' - Kathleen Norris”