(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 15234, 541]*) (*NotebookOutlinePosition[ 16521, 587]*) (* CellTagsIndexPosition[ 16388, 579]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ "ICTCM 12 ", StyleBox["\[FilledSmallCircle]", FontSlant->"Plain"], " Burlingame, CA, 1999" }], "Subsubtitle", CellMargins->{{18, Inherited}, {Inherited, Inherited}}, TextAlignment->Center, TextJustification->0], Cell["Problems about Hill ciphers", "Subtitle", FontFamily->"Helvetica"], Cell[TextData[{ Cell[BoxData[ FormBox[ StyleBox["\[WarningSign]", FontSize->25, Background->RGBColor[1, 1, 0]], TraditionalForm]], FontSize->31, FontWeight->"Bold"], StyleBox[" If you did not tell ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" to evaluate automatically the initialization cell in this \ notebook when you opened it, be sure to evaluate the input cell in the first \ section below.", FontWeight->"Bold"] }], "Text", CellFrame->True, FontColor->RGBColor[1, 0, 0], Background->GrayLevel[0.849989]], Cell[CellGroupData[{ Cell[TextData[{ "The alphabet: global ", StyleBox["alf", FontFamily->"Courier"] }], "Section"], Cell[TextData[{ StyleBox["The following cell was automatically evaluated if you agreed to \ evaluate all initialization cells when you opened this notebook. ", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], " It defines the global constant ", StyleBox["alf", FontFamily->"Courier"], " to be used in Problems 3\[Dash]6. (The expression ", StyleBox["Protect[alf]", FontFamily->"Courier"], " is included to make sure you don't accidentally change the definition.)" }], "Text", CellMargins->{{18, 44}, {Inherited, Inherited}}], Cell["\<\ alf = Characters[\"ABCDEFGHIJKLMNOPQRSTUVWXYZ.? \"] Protect[alf];\ \>", "Input", CellMargins->{{18, 44}, {Inherited, Inherited}}, InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Problem 1: your function ", StyleBox["encipher", FontFamily->"Courier"] }], "Section"], Cell[CellGroupData[{ Cell[TextData[{ "Define your function ", StyleBox["encipher", FontFamily->"Courier"] }], "Subsection"], Cell[TextData[{ "Define a function ", StyleBox["encipher", FontFamily->"Courier", FontWeight->"Bold"], " that enciphers text using a Hill cipher. The function takes two \ arguments and is used in the form\n\t", StyleBox["encipher[plaintxt, A]", FontFamily->"Courier"], "\nwhere:\n\[FilledSmallCircle]", StyleBox[" ", FontFamily->"Times"], StyleBox["plaintxt", FontFamily->"Courier"], " is a character string of elements from alf;\n", StyleBox["\[FilledSmallCircle] ", FontFamily->"Times"], StyleBox["A", FontFamily->"Courier"], " is, for some integer ", Cell[BoxData[ \(TraditionalForm\`n\ > \ 1\)]], ", an ", Cell[BoxData[ \(TraditionalForm\`n\ \[Times]\ n\)]], " matrix with entries in ", Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["Z", FontWeight->"Bold", FontSlant->"Italic"], "m"], TraditionalForm]]], ", where ", Cell[BoxData[ \(TraditionalForm\`m\)]], " is the length of ", StyleBox["alf", FontFamily->"Courier"], "; and\n\[FilledSmallCircle] the result is the ciphertext string that \ results from applying Hill encipherment to ", StyleBox["plaintxt", FontFamily->"Courier"], " with key matrix ", StyleBox["A", FontFamily->"Courier"], "." }], "Text", ParagraphSpacing->{0, 4}], Cell[TextData[{ StyleBox["Example:", FontWeight->"Bold"], "\n\t", StyleBox[" encipher[\"EXAMPLE\", { {9, 8}, {0, 2} }]", FontFamily->"Courier"], "\n\t", StyleBox["RRJYUWKRI", FontFamily->"Courier"], "\nNote that the plaintext here has length 7 whereas the ciphertext has \ length 8." }], "Text", ParagraphSpacing->{0, 4}], Cell[BoxData[ StyleBox[ ButtonBox[ RowBox[{" ", StyleBox[\(My\ Hill\ Work\), FontVariations->{"Underline"->False}]}], ButtonData:>{ FrontEnd`FileName[ { Directory[ ]}, "MyHillWork.nb", "my_encipher_defined", CharacterEncoding -> "WindowsANSI"], None}, ButtonStyle->"Hyperlink", ButtonMargins->6, ButtonNote->"Open my Hill work notebook"], FontFamily->"Helvetica"]], "Text", TextAlignment->Center, TextJustification->0, FontWeight->"Bold"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Validate your function ", StyleBox["encipher", FontFamily->"Courier"] }], "Subsection"], Cell[TextData[{ "A program of mine is going to generate a set of test plaintext strings and \ key matrices and evaluate your function ", StyleBox["encipher", FontFamily->"Courier"], " in turn at each of these plaintext-key matrix pairs. Some of these test \ data pairs are determined by random numbers that depend in part on the digits \ in your student ID numbers. " }], "Text"], Cell["Do the following four steps:", "Text"], Cell[TextData[{ "Be sure that at this ", StyleBox["Mathematica", FontSlant->"Italic"], " session you have defined your ", StyleBox["encipher", FontFamily->"Courier"], " and any other objects it references directly or indirectly, including the \ global ", StyleBox["alf", FontFamily->"Courier"], " from the section \"The alphabet: global ", StyleBox["alf", FontFamily->"Courier"], "\", above. Note that to validate ", StyleBox["encipher", FontFamily->"Courier"], ", you do ", StyleBox["not", FontSlant->"Italic"], " need ", StyleBox["GJmod", FontFamily->"Courier"], ", ", StyleBox["modinv", FontFamily->"Courier"], ", or auxiliary functions for ", StyleBox["GJmod", FontFamily->"Courier"], " and ", StyleBox["modinv", FontFamily->"Courier"], " (because ", StyleBox["encipher", FontFamily->"Courier"], " has no need for them)." }], "Text", CellDingbat->"\[FilledSmallCircle]"], Cell[TextData[{ "Identify yourself\[LongDash]inside the double quotes in the next cell, ", StyleBox["type your student ID number and then evaluate the cell", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], ". " }], "Text", CellDingbat->"\[FilledSmallCircle]"], Cell["\<\ myID = \"23652339\"; (* type your student ID number inside the quotes *)\ \>", "Input"], Cell[TextData[{ "Tell ", StyleBox["Mathematica", FontSlant->"Italic"], " where to look for my validator\[LongDash]", StyleBox["evaluate the following cell now", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], "." }], "Text", CellDingbat->"\[FilledSmallCircle]"], Cell[BoxData[{ \(\(ThePath\ = \ "\";\)\), "\n", \(\(AppendTo[$Path, \ ThePath];\)\)}], "Input"], Cell[TextData[{ "Run the validator that tests your function\[LongDash]", StyleBox[" evaluate the following cell now", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], "." }], "Text", CellDingbat->"\[FilledSmallCircle]"], Cell["Get[\"vdencipher`\"]", "Input"], Cell[TextData[{ "If you have forgotten to define ", StyleBox["myID", FontFamily->"Courier"], " correctly, to evaluate the cell that defines ", StyleBox["alf", FontFamily->"Courier"], ", or to define ", StyleBox["encipher", FontFamily->"Courier"], " or functions of your own that ", StyleBox["encipher", FontFamily->"Courier"], " calls, or if you need to fix up your ", StyleBox["encipher", FontFamily->"Courier"], " to get it to work properly, then you can simply evaluate the preceding \ cell again to run my test program; ", "you may evaluate the preceding cell as many times as you wish", ". (At the same ", StyleBox["Mathematica", FontSlant->"Italic"], " session, you should ", StyleBox["not", FontSlant->"Italic"], " evaluate again the ", StyleBox["Math236Path", FontFamily->"Courier"], "... from the preceding step.)" }], "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Getting your data for Problems 2\[Dash]4\ \>", "Section"], Cell[TextData[{ "Who are you? Inside the double quotes in the next cell, ", StyleBox["type your first name and then evaluate the cell", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], ". " }], "Text", CellDingbat->"\[FilledSmallCircle]"], Cell["\<\ myName = \"Murray\"; (* type your name inside the quotes *)\ \>", "Input"], Cell[TextData[{ "Load the package that creates your plaintext/ciphertext strings and key \ matrix data\[LongDash]", StyleBox["evaluate the following cell now", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], "." }], "Text", CellDingbat->"\[FilledSmallCircle]"], Cell["Get[\"HillData`\"]", "Input"], Cell[TextData[{ "Evaluating the preceding cell will create the text strings and matrices \ you need for Problems 2\[Dash]4, tell you their names, and indicate to which \ problem each one of these data belongs. (Part of your first name, from ", StyleBox["myName", FontFamily->"Courier"], ", will be used in the names of the data.)" }], "Text"], Cell[TextData[{ "If you have forgotten to define myID or ", StyleBox["myName", FontFamily->"Courier"], " correctly, or if you need to re-create your data, then you can simply \ evaluate the preceding cell again, and as many times as you wish. At the \ same ", StyleBox["Mathematica", FontSlant->"Italic"], " session, you should ", StyleBox["not", FontSlant->"Italic"], " evaluate again the ", StyleBox["ThePath", FontFamily->"Courier"], "... cell from the preceding step." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["About problems 2\[Dash]4", "Section"], Cell["\<\ What you are to do for each problem is described below. You \ should: \[FilledSmallCircle] define a separate function for any procedure that you \ apply several times, and for any procedure that someone working with Hill \ ciphers would want to have available; \[FilledSmallCircle] in particular, define a separate function to crack a \ Hill cipher for linearly independent plaintext vectors and corresponding \ ciphertext vectors; and \[FilledSmallCircle] in Problem 4, check for linear independence.\ \>", "Text",\ ParagraphSpacing->{0, 4}] }, Closed]], Cell[CellGroupData[{ Cell["Problem 2: decipher text from inverse key", "Section", CellTags->"problem_2"], Cell["\<\ You are given the inverse of the key matrix for a Hill cipher along \ with some ciphertext. Decipher the text.\ \>", "Text"], Cell[BoxData[ ButtonBox[\(Solution\ to\ 2\), ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookLocate[ #2]}]&), ButtonData:>{"MyHillWork.nb", "problem_2_solved"}, Active->True, ButtonStyle->None, ButtonMargins->6, ButtonNote->ButtonData]], "Text", TextAlignment->Center, TextJustification->0, FontFamily->"Helvetica", FontWeight->"Bold", FontSlant->"Plain", FontColor->RGBColor[0, 0, 1]] }, Closed]], Cell[CellGroupData[{ Cell["Problem 3: decipher text from key", "Section", CellTags->"problem_3"], Cell["\<\ You are given the key matrix for a Hill cipher and a piece of \ ciphertext. You must decipher the ciphertext.\ \>", "Text"], Cell[BoxData[ ButtonBox[\(Solution\ to\ 3\), ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookLocate[ #2]}]&), ButtonData:>{"MyHillWork.nb", "problem_3_solved"}, Active->True, ButtonStyle->None, ButtonMargins->6, ButtonNote->ButtonData]], "Text", TextAlignment->Center, TextJustification->0, FontFamily->"Helvetica", FontWeight->"Bold", FontSlant->"Plain", FontColor->RGBColor[0, 0, 1]] }, Closed]], Cell[CellGroupData[{ Cell["Problem 4: crack a Hill cipher", "Section", CellTags->"problem_4"], Cell[TextData[{ "You have learned the size ", Cell[BoxData[ \(TraditionalForm\`n\)]], " for a certain Hill cipher. You are given a piece of \"captured\" \ plaintext along with the corresponding ciphertext. You will do two things \ with that:\n\[FilledSmallCircle] if possible, find some set of length-", Cell[BoxData[ \(TraditionalForm\`n\)]], " polygraphs among the plaintext that are linearly independent (modulo the \ length of ", StyleBox["alf", FontFamily->"Courier"], "); and\n\[FilledSmallCircle] if the preceding is possible, then use those \ polygraphs to determine the inverse key for this cipher." }], "Text", ParagraphSpacing->{0, 4}], Cell[BoxData[ ButtonBox[\(Cracking\ Theorem\), ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookLocate[ #2]}]&), ButtonData:>{"HowCrack.nb", None}, Active->True, ButtonStyle->None, ButtonMargins->6, ButtonNote->ButtonData]], "Text", TextAlignment->Center, TextJustification->0, FontFamily->"Helvetica", FontWeight->"Bold", FontSlant->"Plain", FontColor->RGBColor[0, 0, 1]], Cell[BoxData[ ButtonBox[\(Solution\ to\ 4\), ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookLocate[ #2]}]&), ButtonData:>{"MyHillWork.nb", "problem_4_solved"}, Active->True, ButtonStyle->None, ButtonMargins->6, ButtonNote->ButtonData]], "Text", TextAlignment->Center, TextJustification->0, FontFamily->"Helvetica", FontWeight->"Bold", FontSlant->"Plain", FontColor->RGBColor[0, 0, 1]] }, Closed]], Cell["Copyright \[Copyright] 1999 by Murray Eisenberg", "Text", TextAlignment->Center, TextJustification->0] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1600}, {0, 1155}}, AutoGeneratedPackage->None, ScreenStyleEnvironment->"Presentation", WindowToolbars->{}, InitializationCellEvaluation->True, CellGrouping->Manual, WindowSize->{872, 927}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, TabSpacings->3, Magnification->1.25, StyleDefinitions -> "Default.nb" ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{ "problem_2"->{ Cell[12029, 429, 85, 1, 59, "Section", CellTags->"problem_2"]}, "problem_3"->{ Cell[12744, 456, 77, 1, 59, "Section", CellTags->"problem_3"]}, "problem_4"->{ Cell[13450, 483, 74, 1, 59, "Section", CellTags->"problem_4"]} } *) (*CellTagsIndex CellTagsIndex->{ {"problem_2", 16107, 566}, {"problem_3", 16198, 569}, {"problem_4", 16289, 572} } *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 244, 8, 85, "Subsubtitle"], Cell[2001, 61, 74, 1, 77, "Subtitle"], Cell[2078, 64, 638, 20, 115, "Text"], Cell[CellGroupData[{ Cell[2741, 88, 102, 4, 97, "Section"], Cell[2846, 94, 558, 13, 147, "Text"], Cell[3407, 109, 169, 5, 68, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[3613, 119, 111, 4, 61, "Section"], Cell[CellGroupData[{ Cell[3749, 127, 110, 4, 87, "Subsection"], Cell[3862, 133, 1347, 47, 316, "Text"], Cell[5212, 182, 349, 12, 158, "Text"], Cell[5564, 196, 559, 16, 52, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[6160, 217, 112, 4, 87, "Subsection"], Cell[6275, 223, 390, 8, 145, "Text"], Cell[6668, 233, 44, 0, 55, "Text"], Cell[6715, 235, 967, 37, 145, "Text"], Cell[7685, 274, 279, 7, 87, "Text"], Cell[7967, 283, 101, 3, 68, "Input"], Cell[8071, 288, 288, 10, 56, "Text"], Cell[8362, 300, 131, 2, 77, "Input"], Cell[8496, 304, 237, 7, 56, "Text"], Cell[8736, 313, 37, 0, 45, "Input"], Cell[8776, 315, 908, 29, 205, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[9733, 350, 67, 2, 59, "Section"], Cell[9803, 354, 259, 7, 87, "Text"], Cell[10065, 363, 88, 3, 68, "Input"], Cell[10156, 368, 279, 8, 87, "Text"], Cell[10438, 378, 35, 0, 45, "Input"], Cell[10476, 380, 353, 7, 115, "Text"], Cell[10832, 389, 521, 16, 115, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[11390, 410, 43, 0, 59, "Section"], Cell[11436, 412, 556, 12, 217, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[12029, 429, 85, 1, 59, "Section", CellTags->"problem_2"], Cell[12117, 432, 135, 3, 85, "Text"], Cell[12255, 437, 452, 14, 61, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[12744, 456, 77, 1, 59, "Section", CellTags->"problem_3"], Cell[12824, 459, 134, 3, 85, "Text"], Cell[12961, 464, 452, 14, 61, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[13450, 483, 74, 1, 59, "Section", CellTags->"problem_4"], Cell[13527, 486, 680, 16, 183, "Text"], Cell[14210, 504, 438, 14, 61, "Text"], Cell[14651, 520, 452, 14, 61, "Text"] }, Closed]], Cell[15118, 537, 112, 2, 46, "Text"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)