(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.2' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 24879, 794] NotebookOptionsPosition[ 22984, 727] NotebookOutlinePosition[ 23391, 745] CellTagsIndexPosition[ 23348, 742] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Polyalphabetic ciphers - Vigenere ciphers", "Section", CellChangeTimes->{{3.624635663236257*^9, 3.624635685740613*^9}}], Cell[TextData[{ "The Vigenere cipher is a combination of several Caesar ciphers. Different \ letters in the plaintext are encrypted with different substitution alphabets.", StyleBox["\n", FontColor->GrayLevel[0]], StyleBox["How it works", FontWeight->"Bold", FontColor->GrayLevel[0]], StyleBox[":", FontColor->GrayLevel[0]], " Correspondents agree on a keyword. \n", StyleBox["To encrypt a plaintext", FontWeight->"Bold", FontColor->GrayLevel[0]], ", one writes the keyword repeatedly alongside the plaintext, converts both \ plaintext and keyword to their numerical equivalents (0-A, 1-B,...25-Z) and \ adds the corresponding letters modulo 26.\n", StyleBox["To decrypt a ciphertext", FontWeight->"Bold", FontColor->GrayLevel[0]], ", one writes the keyword repeatedly alongside the ciphertext, converts both \ ciphertext and keyword to their numerical equivalents (0-A, 1-B,...25-Z) and \ subtracts the corresponding letters modulo 26." }], "Text", CellChangeTimes->{{3.624635716734475*^9, 3.6246359242238007`*^9}, { 3.624636551348486*^9, 3.624636570341045*^9}, {3.6246375587276278`*^9, 3.6246375608885736`*^9}}], Cell[TextData[{ "Keyword ", Cell[BoxData[ FormBox[ RowBox[{"k", "=", RowBox[{ RowBox[{ RowBox[{ SubscriptBox["k", "0"], SubscriptBox["k", "1"], SubscriptBox["k", "2"]}], "..."}], " ", SubscriptBox["k", RowBox[{"n", "-", "1"}]]}]}], TraditionalForm]]], "\nPlaintext ", Cell[BoxData[ FormBox[ RowBox[{" ", RowBox[{"x", "=", RowBox[{ RowBox[{ SubscriptBox["x", "0"], SubscriptBox["x", "1"], SubscriptBox["x", "2"]}], "..."}], " "}]}], TraditionalForm]]], "\nCiphertext ", Cell[BoxData[ FormBox[ RowBox[{" ", RowBox[{"y", "=", RowBox[{ RowBox[{ SubscriptBox["y", "0"], SubscriptBox["y", "1"], SubscriptBox["y", "2"]}], "..."}], " "}]}], TraditionalForm]]], ", where ", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["y", "i"], "=", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["x", "i"], "+", SubscriptBox["k", RowBox[{"(", RowBox[{"i", " ", "mod", " ", "n"}], ")"}]]}], ")"}], "mod", " ", "26"}]}], TraditionalForm]]], "\n" }], "Text", CellChangeTimes->{{3.624637077698962*^9, 3.624637388297553*^9}, { 3.624637569086965*^9, 3.624637573069955*^9}}], Cell[TextData[{ "Example: Ecrypt \[OpenCurlyDoubleQuote]GOAHEAD\[CloseCurlyDoubleQuote] \ using keyword \[OpenCurlyDoubleQuote]WIND\[CloseCurlyDoubleQuote]\n\n", Cell[BoxData[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"plain", "G", "O", "A", "H", "E", "A", "D"}, {"x", "6", "14", "0", "7", "4", "0", "3"}, {"key", "W", "I", "N", "D", "W", "I", "N"}, {"k", "22", "8", "13", "3", "22", "8", "13"}, { RowBox[{"x", "+", RowBox[{"k", " ", RowBox[{"(", RowBox[{"mod", " ", "26"}], ")"}]}]}], StyleBox["2", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["22", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["13", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["10", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["0", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["8", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["16", FontColor->RGBColor[0.6, 0.4, 0.2]]}, {"cipher", StyleBox["C", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["W", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["N", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["K", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["A", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["I", FontColor->RGBColor[0.6, 0.4, 0.2]], StyleBox["Q", FontColor->RGBColor[0.6, 0.4, 0.2]]} }, GridBoxDividers->{ "Columns" -> {False, {True}, False}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}]]] }], "Text", CellChangeTimes->{{3.624636386384535*^9, 3.624636540447303*^9}, { 3.62463658293416*^9, 3.624636613631493*^9}, {3.624637610154385*^9, 3.624637610154408*^9}, {3.624637663891241*^9, 3.6246376812789288`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"Example", ":", " ", RowBox[{ "Decrypt", " ", "\"\\"", " ", "using", " ", "keyword", " ", "\"\\""}]}], " "}], "\[IndentingNewLine]", RowBox[{"(", "\[NoBreak]", GridBox[{ {"cipher", "P", "W", "S", "R", "P", "U", "L", "N", "B"}, {"y", "15", "22", "18", "17", "15", "20", "11", "13", "1"}, {"key", "D", "W", "I", "N", "D", "W", "I", "N", "D"}, {"k", "3", "22", "8", "13", "3", "22", "8", "13", "3"}, { RowBox[{"y", "-", RowBox[{"k", " ", RowBox[{"(", RowBox[{"mod", " ", "26"}], ")"}]}]}], StyleBox["12", FontColor->RGBColor[1, 0, 1]], StyleBox["0", FontColor->RGBColor[1, 0, 1]], StyleBox["10", FontColor->RGBColor[1, 0, 1]], StyleBox["4", FontColor->RGBColor[1, 0, 1]], StyleBox["12", FontColor->RGBColor[1, 0, 1]], StyleBox["24", FontColor->RGBColor[1, 0, 1]], StyleBox["3", FontColor->RGBColor[1, 0, 1]], StyleBox["0", FontColor->RGBColor[1, 0, 1]], StyleBox["24", FontColor->RGBColor[1, 0, 1]]}, {"plain", StyleBox["M", FontColor->RGBColor[1, 0, 1]], StyleBox["A", FontColor->RGBColor[1, 0, 1]], StyleBox["K", FontColor->RGBColor[1, 0, 1]], StyleBox["E", FontColor->RGBColor[1, 0, 1]], StyleBox["M", FontColor->RGBColor[1, 0, 1]], StyleBox["Y", FontColor->RGBColor[1, 0, 1]], StyleBox["D", FontColor->RGBColor[1, 0, 1]], StyleBox["A", FontColor->RGBColor[1, 0, 1]], StyleBox["Y", FontColor->RGBColor[1, 0, 1]]} }, GridBoxDividers->{ "Columns" -> {False, {True}, False}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}]}], "Text",\ CellChangeTimes->{{3.624636676365047*^9, 3.624636683923801*^9}, { 3.624636728651475*^9, 3.6246369890371923`*^9}, {3.624637044634533*^9, 3.624637052081546*^9}, {3.624637591231887*^9, 3.624637598934422*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Index of coincidence of a ciphertext", "Section", CellChangeTimes->{{3.624637444470365*^9, 3.6246374514613457`*^9}}], Cell[TextData[{ StyleBox["Experiment:", FontWeight->"Bold"], " Pick a pair of letters from a text. What is the probability of two letters \ being identical? \nAssume that the text has n letters, counting repetitions, \ distributed as follows: ", Cell[BoxData[ FormBox[ SubscriptBox["n", "0"], TraditionalForm]]], " occurences of \[OpenCurlyDoubleQuote]A\[CloseCurlyDoubleQuote], ", Cell[BoxData[ FormBox[ SubscriptBox["n", "1"], TraditionalForm]]], " occurences of \[OpenCurlyDoubleQuote]B\[CloseCurlyDoubleQuote], ... ", Cell[BoxData[ FormBox[ SubscriptBox["n", "25"], TraditionalForm]]], " occurences of \[OpenCurlyDoubleQuote]Z\[CloseCurlyDoubleQuote], where ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["n", "0"], "+", SubscriptBox["n", "1"], "+"}], "..."}], " ", SubscriptBox["n", "25"]}], "=", "n"}], TraditionalForm]]], ". " }], "Text", CellChangeTimes->{{3.624637513429986*^9, 3.624637518862011*^9}, { 3.6246377517415857`*^9, 3.624637959468204*^9}}], Cell[TextData[{ StyleBox["Counting Probabilities: ", FontWeight->"Bold"], "Total number of ways in which the experiment can turn out: ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"C", RowBox[{"(", RowBox[{"n", ",", "2"}], ")"}]}], "=", StyleBox[ FractionBox[ RowBox[{"n", "(", RowBox[{"n", "-", "1"}], ")"}], "2"], FontSize->18]}], TraditionalForm]]], ".\nTotal number of ways in which identical pairs can be obtained: C(", Cell[BoxData[ FormBox[ SubscriptBox["n", "0"], TraditionalForm]]], ",2)+C(", Cell[BoxData[ FormBox[ SubscriptBox["n", "1"], TraditionalForm]]], ",2)+...C(", Cell[BoxData[ FormBox[ SubscriptBox["n", "25"], TraditionalForm]]], ",2)=", Cell[BoxData[ FormBox[ StyleBox[ RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "0"}], "25"], FractionBox[ RowBox[{ SubscriptBox["n", "i"], "(", RowBox[{ SubscriptBox["n", "i"], "-", "1"}], ")"}], "2"]}], FontSize->18], TraditionalForm]]] }], "Text", CellChangeTimes->{{3.624637999040449*^9, 3.624638260175638*^9}}], Cell[TextData[{ StyleBox["Definition: ", FontWeight->"Bold"], "The number ", Cell[BoxData[ FormBox[ RowBox[{ StyleBox["I", FontSize->18], StyleBox["=", FontSize->18], RowBox[{ StyleBox[ RowBox[{ FractionBox["2", RowBox[{"n", "(", RowBox[{"n", "-", "1"}], ")"}]], RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "0"}], "25"], FractionBox[ RowBox[{ SubscriptBox["n", "i"], "(", RowBox[{ SubscriptBox["n", "i"], "-", "1"}], ")"}], "2"]}]}], FontSize->18], StyleBox["=", FontSize->18], RowBox[{ StyleBox[ FractionBox["1", RowBox[{"n", "(", RowBox[{"n", "-", "1"}], ")"}]], FontSize->18], RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "0"}], "25"], RowBox[{ SubscriptBox["n", "i"], "(", RowBox[{ SubscriptBox["n", "i"], "-", "1"}], ")"}]}]}]}]}], TraditionalForm]]], " is called the index of coincidence of the ciphertext. It represents the \ probability that two letters selected at random from the ciphertext are \ identical." }], "Text", CellChangeTimes->{ 3.6246382347138367`*^9, {3.624638299960479*^9, 3.624638451347664*^9}, { 3.6584479584074087`*^9, 3.658447989030879*^9}}], Cell[TextData[{ "The index of coincidence of an alphabet in which each letter has the same \ frequency is ", StyleBox["1/26 \[TildeEqual]", FontWeight->"Bold"], " ", StyleBox["0.0385", FontWeight->"Bold", FontSlant->"Italic"], " \nThe index of coincide of the English alphabet is about ", StyleBox["0.065", FontWeight->"Bold"] }], "Text", CellChangeTimes->{{3.624639237378783*^9, 3.624639292081874*^9}, { 3.624639358594987*^9, 3.624639360858795*^9}, {3.624639398028954*^9, 3.6246394646720667`*^9}}], Cell[TextData[{ StyleBox["Monoalphabetic substitution (Caesar, Affine, Permutation): ", FontWeight->"Bold"], Cell[BoxData[ FormBox[ RowBox[{ StyleBox["I", FontSize->18, FontWeight->"Plain"], "\[TildeEqual]", " ", "0.065"}], TraditionalForm]], FontWeight->"Bold"], "\n", StyleBox["Polyalphabetic substitution (Vigenere cipher): ", FontWeight->"Bold"], " ", StyleBox["I ", FontSize->16, FontWeight->"Bold", FontSlant->"Italic"], StyleBox["\[TildeEqual] (closer to) 0.0385 \n", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["Vigenere ciphers from longer keywords have a more uniform \ distribution of letters, so the index of coincidence is closer to 0.0385. If \ the keyword is short, then the index of coincidence is closer to 0.065.", FontSlant->"Italic"] }], "Text", CellChangeTimes->{{3.624638494146227*^9, 3.624638547613082*^9}, { 3.624638958997775*^9, 3.624639169054081*^9}, {3.6246430956266613`*^9, 3.6246431375131893`*^9}, {3.624644411404088*^9, 3.6246444839476833`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Connection between I and the keyword length", "Section", CellChangeTimes->{{3.6246394973934393`*^9, 3.624639509936489*^9}}], Cell[TextData[{ StyleBox["Formula (Friedman\[CloseCurlyQuote]s Test): ", FontWeight->"Bold"], "Suppose that a ciphetext with n letters was obtained by a Vigenere encoding \ using a keyword with length k.", StyleBox[" ", FontWeight->"Bold"], "Then the length of the keyword is approximatively", StyleBox[" ", FontWeight->"Bold"], Cell[BoxData[ FormBox[ StyleBox[ RowBox[{ StyleBox["k", FontWeight->"Plain"], StyleBox[" ", FontWeight->"Bold"], StyleBox["\[TildeEqual]", FontWeight->"Bold"], StyleBox[ FractionBox[ RowBox[{"0.0265", " ", "n"}], RowBox[{ RowBox[{"(", RowBox[{"0.065", "-", "I"}], ")"}], "+", RowBox[{"n", "(", RowBox[{"I", "-", "0.0385"}], ")"}]}]], FontWeight->"Bold"]}], FontSize->18, Background->RGBColor[1, 1, 0.85]], TraditionalForm]]], "." }], "Text", CellChangeTimes->{{3.624639523462475*^9, 3.624639715439127*^9}, { 3.624643299461257*^9, 3.624643307549444*^9}}], Cell[CellGroupData[{ Cell["How it works :", "Subsection", CellChangeTimes->{{3.6581452367982073`*^9, 3.65814525336465*^9}}], Cell["\<\ Suppose that the ciphertext has n letters and the Vigenere keyword has k \ letters. Assume for simplicity that n is a multiple of k. We can group the \ letters of the ciphertext in a table with k columns and n/k rows, where the \ letters in each column are encoded with the same ciphertext. \ \>", "Text", CellChangeTimes->{{3.658145270043943*^9, 3.65814530062752*^9}, 3.6581455866271257`*^9, {3.658145617275242*^9, 3.658145647524374*^9}, { 3.65814568476858*^9, 3.658145708585847*^9}, {3.6581458316740913`*^9, 3.658145950138569*^9}, {3.658146161753853*^9, 3.658146201777063*^9}}], Cell["\<\ Each column is a shift encipherment by an ammount corresponding to the key \ letter. If we choose a pair of letters at random, then they either:\ \>", "Text", CellChangeTimes->{{3.658145739550375*^9, 3.658145790964837*^9}, 3.6581458230559*^9, {3.658145987044581*^9, 3.6581459952787867`*^9}}], Cell[CellGroupData[{ Cell["come from the same column", "ItemNumbered", CellChangeTimes->{{3.658145997529511*^9, 3.6581460123887568`*^9}}], Cell["come from different columns", "ItemNumbered", CellChangeTimes->{{3.658145997529511*^9, 3.658146030751567*^9}}] }, Open ]], Cell["\<\ Let' s analyze these two situations, and compute te probability that the \ chosen letters are identical.\ \>", "Text", CellChangeTimes->{{3.65814608303025*^9, 3.658146126661047*^9}, { 3.658146744243808*^9, 3.6581467449637947`*^9}}], Cell[CellGroupData[{ Cell["Case 1.", "Subsubsection", CellChangeTimes->{{3.658146278974691*^9, 3.658146295345525*^9}}], Cell[TextData[{ "We have", StyleBox[" k", FontWeight->"Bold"], " ways to choose the column and ", StyleBox["C(n/k, 2)", FontWeight->"Bold"], " ways to choose a pair of letters from the same column.\nSince letters from \ the same column are encrypted using the same Caesar cipher, they have \ probabilty ", StyleBox["0.065", FontWeight->"Bold"], " to be identical. ", StyleBox["The expected number of identical pairs of letters from the same \ column is:", FontWeight->"Bold"], "\n", StyleBox["S = 0.065*k*C(n/k, 2)", FontSize->16, FontWeight->"Bold", FontSlant->"Italic", FontColor->GrayLevel[0], Background->RGBColor[1, 1, 0.85]] }], "Text", CellChangeTimes->{{3.658146235598083*^9, 3.658146260775937*^9}, { 3.658146299451745*^9, 3.65814645123943*^9}, {3.658146925414982*^9, 3.6581469364360037`*^9}, {3.658448105340476*^9, 3.658448106477248*^9}}, TextJustification->1.] }, Open ]], Cell[CellGroupData[{ Cell["Case 2.", "Subsubsection", CellChangeTimes->{{3.658146278974691*^9, 3.658146295345525*^9}, { 3.65814647349056*^9, 3.658146473977132*^9}}], Cell[TextData[{ "We have ", StyleBox["C(k,2)", FontWeight->"Bold"], " ways to choose two distinct columns and ", StyleBox["n/k ", FontWeight->"Bold"], "ways to choose a letter in the first chosen column, and likewise, also ", StyleBox["n/k ", FontWeight->"Bold"], "ways to choose a letter in the second column.\nSince letters from different \ columns are encrypted using different Caesar ciphers, they have probabilty ", StyleBox["1/26 = 0.0385", FontWeight->"Bold"], " to be identical. ", StyleBox["The expected number of identical pairs of letters from different \ columns is:", FontWeight->"Bold"], "\n", StyleBox["D = 0.0385*C(k, 2)* ", FontSize->16, FontWeight->"Bold", FontSlant->"Italic", Background->RGBColor[1, 1, 0.85]], Cell[BoxData[ FormBox[ SuperscriptBox[ RowBox[{ StyleBox["(", FontSize->24], StyleBox[ FractionBox["n", "k"], FontSize->18, FontWeight->"Bold"], StyleBox[")", FontSize->24]}], StyleBox["2", FontWeight->"Bold"]], TraditionalForm]], FontSize->16, FontSlant->"Italic", Background->RGBColor[1, 1, 0.85]] }], "Text", CellChangeTimes->{{3.658146235598083*^9, 3.658146260775937*^9}, { 3.658146299451745*^9, 3.6581464833180227`*^9}, {3.658146534470503*^9, 3.658146539867474*^9}, {3.658146573329372*^9, 3.658146727895234*^9}, { 3.658146763144734*^9, 3.658146866176663*^9}, {3.658146915627027*^9, 3.6581469192544394`*^9}, {3.658448110431436*^9, 3.658448111911536*^9}}, TextJustification->1.] }, Open ]], Cell[CellGroupData[{ Cell["Conclusion (Case 1 + Case 2)", "Subsubsection", CellChangeTimes->{{3.658146897986876*^9, 3.658146907897256*^9}, { 3.6581469615790787`*^9, 3.6581469726620502`*^9}, {3.658448234056573*^9, 3.658448242058715*^9}}], Cell[TextData[{ "The index of coincidence of the ciphertext will be ", StyleBox[" ", Background->RGBColor[1, 1, 0.85]], Cell[BoxData[ RowBox[{ RowBox[{ StyleBox["I", FontSize->24, FontSlant->"Italic"], StyleBox[" ", FontSize->24, FontWeight->"Bold"], StyleBox["\[TildeEqual]", FontSize->24, FontWeight->"Bold"], StyleBox[" ", FontWeight->"Bold"], StyleBox[ FractionBox[ RowBox[{"S", " ", "+", " ", "D"}], RowBox[{"C", RowBox[{"(", RowBox[{"n", ",", "2"}], ")"}]}]], FontSize->24, FontWeight->"Bold", FontSlant->"Italic"]}], StyleBox["=", FontSize->24, FontWeight->"Bold"], StyleBox[ FractionBox[ StyleBox[ RowBox[{ RowBox[{"0.065", "*", RowBox[{"(", RowBox[{"n", "-", "k"}], ")"}]}], " ", "+", " ", RowBox[{"0.0385", "*", "n", RowBox[{"(", RowBox[{"k", "-", "1"}], StyleBox[")", Background->RGBColor[1, 1, 0.85]]}]}]}], FontSize->16, FontWeight->"Bold"], StyleBox[ RowBox[{"k", RowBox[{"(", RowBox[{"n", "-", "1"}], ")"}]}], FontSize->16, FontWeight->"Bold"]], "Text", FontSize->7, FontSlant->"Italic"], StyleBox[" ", FontSize->24, FontWeight->"Bold"]}]], CellChangeTimes->{{3.658146977890889*^9, 3.658147099590837*^9}, { 3.6581471398523407`*^9, 3.6581471414827347`*^9}, {3.6584482120294647`*^9, 3.6584482186954*^9}, 3.6584482531215487`*^9}, Background->RGBColor[1, 1, 0.85]] }], "Text", CellChangeTimes->{{3.6584482575121937`*^9, 3.658448289219599*^9}, { 3.658448358841249*^9, 3.6584483832646437`*^9}, {3.658448420752647*^9, 3.6584484409925613`*^9}, {3.658448517777527*^9, 3.658448529998179*^9}, { 3.65844860789989*^9, 3.658448610077127*^9}}], Cell[TextData[{ "If we want to guess a probable keyword length k from the index of \ coincidence of a ciphertext, we take the previous equation and solve for k. \ We obtain Friedman\[CloseCurlyQuote]s formula: ", Cell[BoxData[ FormBox[ StyleBox[ RowBox[{ StyleBox["k", FontWeight->"Plain"], StyleBox[" ", FontWeight->"Bold"], StyleBox["\[TildeEqual]", FontWeight->"Bold"], StyleBox[ FractionBox[ RowBox[{"0.0265", " ", "n"}], RowBox[{ RowBox[{"(", RowBox[{"0.065", "-", "I"}], ")"}], "+", RowBox[{"n", "(", RowBox[{"I", "-", "0.0385"}], ")"}]}]], FontWeight->"Bold"]}], FontSize->18], TraditionalForm]], FontSize->18] }], "Text", CellChangeTimes->{{3.658147523428442*^9, 3.6581475891763268`*^9}, { 3.6581476423844757`*^9, 3.658147662447886*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Exercise: ", "Subsubsection", CellChangeTimes->{{3.624643234996202*^9, 3.6246432373156233`*^9}}], Cell[TextData[{ "The following ciphertext was produced using a Vigenere cipher with a \ keyword of unknown length k. \n\[OpenCurlyDoubleQuote]", StyleBox[\ "KIVQXTCQQVRPQOSGWEKVMTRYNHJVUVVKBMDPKVHKWBUWFVZFNOPQOSGWEKVMTRYNHJGDPKOV", FontWeight->"Bold"], "\[CloseCurlyDoubleQuote]." }], "Text", CellChangeTimes->{{3.624643248859439*^9, 3.624643287090764*^9}, { 3.6246433254568768`*^9, 3.624643381340139*^9}, {3.624643413336318*^9, 3.6246435257661953`*^9}, {3.624643783502295*^9, 3.624643906480476*^9}, { 3.6246447759626102`*^9, 3.62464477980121*^9}, {3.624644984250828*^9, 3.6246449868348303`*^9}, 3.6246450329888077`*^9}], Cell[CellGroupData[{ Cell["\<\ Write a function that computes the index of coincidence of a ciphertext.\ \>", "Item", CellChangeTimes->{{3.624643631175747*^9, 3.62464364110749*^9}, { 3.624643750079257*^9, 3.624643762479467*^9}, {3.624644280712347*^9, 3.624644302008439*^9}}], Cell["\<\ Find an approximation of the length of the keyword, using Friedman's test. \ Now you know that approximatively k Caesar ciphers were used to encode the \ text.\ \>", "Item", CellChangeTimes->{{3.624643631175747*^9, 3.62464364110749*^9}, { 3.624643750079257*^9, 3.624643762479467*^9}, 3.624644280712347*^9, { 3.6246443139204607`*^9, 3.624644319168539*^9}}], Cell["\<\ Try to break all of them. If frequency analysis does not work, then use the \ additional information that the cipher block \[OpenCurlyDoubleQuote]PQOSG\ \[CloseCurlyDoubleQuote] is an encoding for the plaintext \ \[OpenCurlyDoubleQuote]SOLVE\[CloseCurlyDoubleQuote]. \ \>", "Item", CellChangeTimes->{{3.624643631175747*^9, 3.624643723204406*^9}, { 3.624643787830535*^9, 3.624643787835664*^9}, {3.624644187407617*^9, 3.624644200745769*^9}, 3.624644255344522*^9, {3.624645001483047*^9, 3.624645003978697*^9}}], Cell["Decode the ciphertext.", "Item", CellChangeTimes->{{3.624643631175747*^9, 3.624643723204406*^9}, { 3.624643787830535*^9, 3.624643794078418*^9}}] }, Open ]] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{1280, 671}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, FrontEndVersion->"10.2 for Mac OS X x86 (32-bit, 64-bit Kernel) (July 29, \ 2015)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 126, 1, 64, "Section"], Cell[709, 25, 1144, 26, 125, "Text"], Cell[1856, 53, 1271, 49, 95, "Text"], Cell[3130, 104, 1866, 50, 156, "Text"], Cell[4999, 156, 2037, 60, 150, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[7073, 221, 123, 1, 64, "Section"], Cell[7199, 224, 1058, 30, 51, "Text"], Cell[8260, 256, 1119, 41, 80, "Text"], Cell[9382, 299, 1366, 47, 67, "Text"], Cell[10751, 348, 519, 15, 49, "Text"], Cell[11273, 365, 1036, 29, 91, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[12346, 399, 130, 1, 64, "Section"], Cell[12479, 402, 1020, 34, 68, "Text"], Cell[CellGroupData[{ Cell[13524, 440, 103, 1, 44, "Subsection"], Cell[13630, 443, 603, 10, 68, "Text"], Cell[14236, 455, 306, 5, 30, "Text"], Cell[CellGroupData[{ Cell[14567, 464, 117, 1, 30, "ItemNumbered"], Cell[14687, 467, 117, 1, 30, "ItemNumbered"] }, Open ]], Cell[14819, 471, 244, 5, 30, "Text"], Cell[CellGroupData[{ Cell[15088, 480, 98, 1, 35, "Subsubsection"], Cell[15189, 483, 905, 27, 90, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[16131, 515, 146, 2, 35, "Subsubsection"], Cell[16280, 519, 1528, 47, 107, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[17845, 571, 221, 3, 35, "Subsubsection"], Cell[18069, 576, 1860, 63, 52, "Text"], Cell[19932, 641, 870, 27, 65, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[20839, 673, 103, 1, 35, "Subsubsection"], Cell[20945, 676, 640, 12, 49, "Text"], Cell[CellGroupData[{ Cell[21610, 692, 259, 5, 28, "Item"], Cell[21872, 699, 372, 7, 28, "Item"], Cell[22247, 708, 529, 9, 28, "Item"], Cell[22779, 719, 153, 2, 28, "Item"] }, Open ]] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)