(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 5260, 152] NotebookOptionsPosition[ 4674, 130] NotebookOutlinePosition[ 5013, 145] CellTagsIndexPosition[ 4970, 142] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{"Caesar", " ", "Cipher"}], "\[IndentingNewLine]"}]], "Input", CellChangeTimes->{{3.409840871168672*^9, 3.4098408745835824`*^9}, { 3.4098421387814093`*^9, 3.4098421404838576`*^9}}], Cell[BoxData[ RowBox[{"Alphabet", "=", RowBox[{"CharacterRange", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}]}]], "Input", CellChangeTimes->{{3.409840877698061*^9, 3.409840901362088*^9}}], Cell[BoxData[ RowBox[{"CaesarAlphabet", "=", RowBox[{"RotateRight", "[", RowBox[{"Alphabet", ",", "16"}], "]"}]}]], "Input", CellChangeTimes->{{3.4098409067298064`*^9, 3.40984093261703*^9}, { 3.4098413982465725`*^9, 3.40984139912784*^9}, {3.4098421435382495`*^9, 3.4098421441991997`*^9}}], Cell[BoxData[ RowBox[{"CaesarRule", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Alphabet", "[", RowBox[{"[", "i", "]"}], "]"}], "\[Rule]", RowBox[{"CaesarAlphabet", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "26"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.409840936152114*^9, 3.4098409746074095`*^9}, { 3.4098421511692224`*^9, 3.409842155765832*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"CaesarCipher", "[", RowBox[{"message_", ",", "shift_"}], "]"}], ":=", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"Alphabet", "=", RowBox[{"CharacterRange", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}]}], ";", RowBox[{"CaesarAlphabet", "=", RowBox[{"RotateRight", "[", RowBox[{"Alphabet", ",", "shift"}], "]"}]}], ";", RowBox[{"CaesarRule", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Alphabet", "[", RowBox[{"[", "i", "]"}], "]"}], "\[Rule]", RowBox[{"CaesarAlphabet", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "26"}], "}"}]}], "]"}]}], ";", RowBox[{"StringJoin", "[", RowBox[{"ReplaceAll", " ", "[", RowBox[{ RowBox[{"Characters", "[", "message", "]"}], ",", "CaesarRule"}], "]"}], "]"}]}], ")"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"(*", RowBox[{ RowBox[{ "StringJoin", " ", "takes", " ", "a", " ", "list", " ", "of", " ", "characters"}], "-", RowBox[{"separated", " ", "by", " ", "commas"}], "-", RowBox[{ "and", " ", "concatenates", " ", "them", " ", "into", " ", "a", " ", "string"}], "-", RowBox[{"no", " ", "commas", " ", "no", " ", "spaces"}]}], "*)"}]}]}], "Input", CellChangeTimes->{{3.4098409928736753`*^9, 3.4098411651313696`*^9}, { 3.409841758244224*^9, 3.4098418204236336`*^9}, {3.409842067288608*^9, 3.4098420954090433`*^9}, {3.4098421586599936`*^9, 3.4098421785886497`*^9}, { 3.4098422597253184`*^9, 3.409842367239917*^9}}], Cell[BoxData[ RowBox[{"Characters", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.4098422547281327`*^9, 3.409842257291819*^9}, { 3.4098424345867567`*^9, 3.4098424604940095`*^9}}], Cell[BoxData[ RowBox[{"ReplaceAll", "[", RowBox[{"%", ",", "CaesarRule"}], "]"}]], "Input", CellChangeTimes->{{3.40984246791468*^9, 3.4098424910379295`*^9}}], Cell[BoxData[ RowBox[{"StringJoin", "[", "%", "]"}]], "Input", CellChangeTimes->{{3.409842494352696*^9, 3.4098425083327985`*^9}}], Cell[BoxData[ RowBox[{"CaesarCipher", "[", RowBox[{"\"\\"", ",", "16"}], "]"}]], "Input", CellChangeTimes->{{3.4098411785106077`*^9, 3.40984120075259*^9}, { 3.4098413645881743`*^9, 3.4098413650488367`*^9}, {3.4098414216201825`*^9, 3.4098414223712626`*^9}, {3.409841733889203*^9, 3.4098417344900675`*^9}, { 3.4098421813426094`*^9, 3.4098421820436172`*^9}}], Cell[BoxData[ RowBox[{"CaesarCipher", "[", RowBox[{"%", ",", RowBox[{"-", "16"}]}], "]"}]], "Input", CellChangeTimes->{{3.409841282059504*^9, 3.409841292774912*^9}, { 3.409841428550147*^9, 3.4098414652328944`*^9}, 3.409841598744875*^9, { 3.4098417380852365`*^9, 3.409841739076662*^9}, {3.4098421838662386`*^9, 3.4098421909964914`*^9}}] }, WindowSize->{615, 559}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (June 19, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 216, 4, 52, "Input"], Cell[787, 27, 203, 4, 31, "Input"], Cell[993, 33, 302, 6, 31, "Input"], Cell[1298, 41, 462, 12, 31, "Input"], Cell[1763, 55, 1668, 42, 152, "Input"], Cell[3434, 99, 200, 3, 31, "Input"], Cell[3637, 104, 162, 3, 31, "Input"], Cell[3802, 109, 131, 2, 31, "Input"], Cell[3936, 113, 377, 6, 31, "Input"], Cell[4316, 121, 354, 7, 31, "Input"] } ] *) (* End of internal cache information *)