Math 455.1  • 29 March 2009

Get your ciphertext for Set 5 # 3

Copyright © 2009 by Murray Eisenberg.  All rights reserved.

This notebook creates the ciphertext you will use for Problem #3 of Set 5.

Clear[myctxt];myctxt=Module[{nb,id,str="",identifier,which,where,ok=True,digits=Characters["0123456789"],
nums={0,8073,19661,24683,27652,28591,30692,31201,35120,64850,73489,79212,81782,95809,102010,108506,110241,126858,137493,153566,160073,162879,178762,219849,229494,232344,259438,278725,300919,303263,319337,341194,345321,347971,361634,394341,404482,412271,428747,431363,438483,443030},
texts = {"MBFXMHMABGDGHP","RWNFXDYEYMLYX","KPQNADQSECDQAZS","PKGPCXAFLPLKWXI","PILXTYPWPXPYED","AOAKNAWZARRSNOS","MVYLCLYWYLZLUA","CNBCCQRBLRYQNA","QXHBQLTXQBO","RSCVKFRCCFNRTK","VIDHVGXMVXFZMN","AWAMNOJABXIIL","ZVWQNMZCKCJDIQZ","PAYQANAJHSYPW","CFAZFTAUYNSAPMM","QPABXEOAZBZAN","HDVLHVWWKHRUB","QTPIPIIATIPAT","GJDTSIJQJRJSYFWD","ZLZMZOKZMOZMZLZ","VFOKBOVCUATQAVF","UDUXJANRMULOMR","FADYQULNQYALGTQ","PLUXPKKNPLPXUAV","DPNCPEDPITDESPCP","RSBBSFQSXSFEIZSFS","LUJYFWALKTLZZHNL","BNCCQNXAHORABC","ZXKQVLRJXQZEFQ","JFDVKYZEXNVZIUVI","VIVYQZIOPMZVCZVY","SAJRGSAJMQORGTG","NQMBZAZZBICRIVA","TMJIWVWAHTWJI","FYKMFQFVYNENQO","JENVDXCWCOPCD","ZKHQDUHBRXUHDGB","ITHIVGPEWIWTDGN","JCFRNSJQJRJSYX","ZFZHMZBGZKKDMFD","LKBOPOBHBOYONV","RUMRRJOMKOXJUH"}
},
While[ok==True,
DialogInput[
Column[{
TextCell["Type your UMass ID number"],
Style[InputField[Dynamic[str],String,FieldSize->{8,1.25}],FontSize->12],
DefaultButton[DialogReturn[str]]
}]];
ok=Not[(StringLength[str]≥6) && And@@(MemberQ[digits,#]&)/@Characters[str]];
id=str;str="";
];
identifier=Mod[FromDigits@Take[IntegerDigits[ToExpression[id]],-6],455219];
which=If[{}≠ (where=Flatten@Position[nums,identifier]),First@where,RandomInteger[{1,Length[texts]}]];
nb=SelectedNotebook[];SelectionMove[nb,After,EvaluationCell];
NotebookWrite[nb,Cell[BoxData[RowBox[{StyleBox["Your cipher text is ready! It's stored in variable  ",StripOnInput->False,FontFamily->"Times",FontSize->16,FontColor->RGBColor[1,0,0]],"",StyleBox["myctxt",StripOnInput->False,FontSize->16,FontWeight->"Bold"]}]],
"PinkComments"]];
texts [[which ]]
];
Remove[nb,id,str,identifier,which,where,ok,digits,nums,texts];

myctxt

To save your cipher text: store the value of that variable in the notebook where you are doing the work to decrypt your cipher text. Then you won't have to open this notebook again to retrieve your cipher text later on.