alphabet0 = "abcdefghijklmnopqrstuvwxyz";
key[n_] := 
        Table[StringTake[alphabet0, {i}]  ->  
            StringTake[alphabet0, {Mod[i - 1 + n, 26] + 1}], {i, 1, 
            26}];
shift[plaintext_, n_] :=  
        StringReplace[plaintext,  key[n]];
affkey[m_, n_] := 
        Table[StringTake[alphabet0, {i}]  ->  
            StringTake[alphabet0, {Mod[m*(i - 1) + n, 26] + 1}], {i, 1, 
            26}];
affinecrypt[plaintext_, m_, n_] :=  
        StringReplace[plaintext,  affkey[m, n]];
allshifts[txt_] := 
        Module[{}, Print[txt]; 
          Do[Print[shift[txt, n]], {n, 25}]];
ycve = "ycvejqwvhqtdtwvwu";
edsg = "edsgickxhuklzveqzvkxwkzukcvuh";
tcab = "tcabtiqmfheqqmrmvmtmaq";  
    lcll = "lcllewljazlnnzmvyiylhrmhza"; 
DNA = "GAATTCGCGGCCGCAATTAACCCTCACTAAAGGGATCTCTAGAACT";

vigkey[m_, n_] := 
        Table[StringTake[alphabet0, {i}]  ->  
            StringTake[
              alphabet0, {Mod[i - 1 + m[[Mod[n - 1, Length[m]] + 1]], 
                    26] + 1}], {i, 1, 26}];
vigenere[plaintext_, v_] := 
        StringJoin[
Module[{z}, z = {}; 
            Do[z = Insert[z, 
                  StringReplace[Characters[plaintext][[i]], 
                    vigkey[v, Mod[i - 1, Length[v]] + 1]], i], {i, 
                StringLength[plaintext]}]; z]];
choose[txt_, m_, n_] := 
        StringJoin[
          Module[{z}, z = {}; 
            For[i = 1, 
              m*(i - 1) + n  <  1 + StringLength[txt], i++, 
              z = Insert[z, StringTake[txt, {m*(i - 1) + n}], i]]; 
            z]];
frequency[txt_] := 
        Array[Function[
            i, {Characters[alphabet0][[i]], 
              Count[Characters[txt], Characters[alphabet0][[i]]]}], 
          26];
vigvec[txt_, m_, n_] := 
        Module[{z, w}, z = choose[txt, m, n]; 
          w = Table[frequency[z][[i]][[2]]/
                  StringLength[z]*1. , {i, 1, 
                26}]; 
w];
alfreq = { .082,  .015,  .028,  .043,  .127,  .022,  .020,  .061,  .070,  .002,  .008,  .040,  .024,  .067,  .075,  .019,  .001,  .060,  .063,  .091,  .028,  .010,  .023,  .001,  .020,  .001};
s[a_, b_, n_] := 
        Sum[a[[i]]*b[[Mod[i - n - 1, 26] + 1]], {i, 26}];
\(\(corr[a_] := 
        Table[s[a, alfreq, i], {i, 0, 25}];\)

\)
\(\(xkju = "xkjurowmllpxwznpimbvbqjcnowxpcchhvvfvsllfvxhazityxohulxqojaxelxzxmyjaqfstsrulhhucdskbxknjqidallpqslluhiaqfpbpcidsvcihwhwewthbtxrljnrsncihuvffuxvoukjljswmaqfvjwjsdyljogjxdboxajultucpzmpliwmlubzxvoodybafdskxgqfadshxnxehsaruojaqfpfkndhsaafvulluwtaqfrupwjrszxgpfutjqiynrxnyntwmhcukjfbirzsmehhsjshyonddzzntzmplilrwnmwmlvuryonthuhabwnvw";\)\)
\(\(\(ocwy = "ocwyikoooniwugpmxwktzdwgtssayjzwyemdlbnqaaavsuwdvbrflauplooubfgqhgcscmgzlatoedcsdeidpbhtmuovpiekifpimfnoamvlpqfxejsmxmpgkccaykwfzpyuavtelwhrhmwkbbvgtguvtefjlodfefkvpxsgrsorvgtajbsauhzrzalkwuowhgedefnswmrciwcpaaavogpdnfpktdbalsisurlnpsjyeatcuceesohhdarkhwotikbroqrdfmzghgucebvgwcdqxgpbgqwlpbdaylooqdmuhbdqgmyweuik";\)\(
\)
    \)\)

\(coinc[text1_, shift_] := 
      Module[{z, a, b}, z = 0; a = 
			Characters[text1]; 
        b = Drop[a, shift]; a = Drop[a, \(-shift\)]; 
        Do[If[a[\([i]\)] == 
					b[\([i]\)], z = z + 1, \ \ ], {i, 
            StringLength[text1] - shift}]; z]\)

\(\(hdsf = "hdsfgvmkoowafweetcmfthskucaqbilgjofmaqlgspvatvxqbiryscpcfrmvswrvnqlszdmgaoqsakmlupsqforvtwvdfcjzvgsoaoqsacjkbrsevbelvbksarlscdcaarmnvrysywxqgvellcyluwwveoafgclazowafojdlhssfiksepsoywxafowlbfcsocylngqsyzxgjbmlvgrggokgfgmhlmejabsjvgmlnrvqzcrggcrghgeupcyfgtydycjkhqluhgxgzovqswpdvbwsffsenbxapasgazmyuhgsfhmftayjxmwznrsofrsoaopgauaaarmftqsmahvqecev";\)\)

\(\(vvhq = "vvhqwvvrhmusgjgthkihtssejchlsfcbgvwcrlryqtfsvgahwkcuhwauglqhnslrljshbltspisprdxljsveeghlqwkasskuwepwqtwvspgoelkcqyfnsvwljsniqkgnrgybwlwgoviokhkazkqkxzgyhcecmeiujoqkwfwvefqhkijrclrlkbienqfrjljsdhgrhlsfqtwlauqrhwdmwlgusgikkflryvcwvspgpmlkassjvoqxeggveyggzmljcxxljsvpaivwikvrdrygfrjljslveggveyggeiapuuisfpbtgnwwmuczrvtwglrwugumnczvile";\)\)

\(

\(lfsr[c_, k_, n_] := 
        Module[{z}, z = k; 
          Do[z = Append[z, 
                Mod[Array[Function[i, z[\([j - Length[k] - 1 + i]\)]], 
                      Length[k]] . c, 2]], {j, Length[k] + 1, n}]; 
          z];\)\)
lfsrlength[v_, n_] := 
Do[
        Print[{k, 
            Mod[Det[Array[Function[{i, j}, v[[i + j - 1]]], {k, k}]], 
              2]}], {k, 
          Min[n, 1 + 
              Floor[Dimensions[v][[1]]/
                  2]]}]
lfsrmatrix[v_, n_] := 
        Array[Function[{i, j}, v[[i + j - 1]]], {n, 
            n}];
lfsrsolve[v_, n_] := 
        Module[{z}, z = Array[Function[{i, j}, v[[i + j - 1]]], {n, n}]; 
          Mod[Det[z]*Inverse[z] . Array[Function[i, v[[i + n]]], n], 
            2]];
ss[m_, l_] := Do[Print[s[j, l]], {j, m}];
c7 = {1, 1, 0, 0, 0, 0, 0};
k7 = {1, 1, 0, 0, 0, 1, 1};
L100 = {1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 
          0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 
          1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 
          0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 
          0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0};
L011 = {0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 
          0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 
          0, 1, 1, 1, 0, 1, 0, 1};
L101 = {1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 
          1, 
0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 
          1, 1, 1, 
1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 
          1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 
          0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 
          0};

<< NumberTheory`NumberTheoryFunctions`

rsan = 
        114381625757888867669235779976146612010218296721242362562561842935706935245733897830597123563958705058989075147599290026879543541;
rsae = 9007;
\(\(\(rsaci = 
        96869613754622061477140922254355882905759991124574319874695120930816298225145708356931476622883989628013391990551829945157815154;\)\(
\)
    \)\)

rsap = 
        3490529510847650949147849619903898133417764638493387843990820577;
\(\(\(rsaq = 
        32769132993266709549961988190834461413177642967992942539798288533;\)\(
\)
    \)\)

alphabet1 = " abcdefghijklmnopqrstuvwxyz";
\(\(numbers1 = "000102030405060708091011121314151617181920212223242526";\)\)
quantify1 = 
        Table[StringTake[alphabet1, {i}]  ->  
            StringTake[numbers1, {2*i - 1, 2*i}], {i, 1, 27}];
txt2num1[plaintext_] := 
        ToExpression[
          StringReplace[plaintext, quantify1]];
\(\(numbers0 = "0001020304050607080910111213141516171819202122232425";\)\)
quantify0 = 
        Table[StringTake[alphabet0, {i}]  ->  
            StringTake[numbers0, {2*i - 1, 2*i}], {i, 1, 26}];
txt2num0[plaintext_] := 
        ToExpression[
          StringReplace[plaintext, quantify0]];
\(\(num2txt1[n_] := 
        Module[{c, x, z}, x = n; c = Characters[alphabet1]; z = {}; 

          While[x > 0, z = Prepend[z, c[\([Mod[x, 100] + 1]\)]]; 

            x = Floor[x/100]]; StringJoin[z]];\)\)
\(\(num2txt0[n_] := 
        Module[{c, x, z}, x = n; c = Characters[alphabet0]; z = {}; 

          While[x > 0, z = Prepend[z, c[\([Mod[x, 100] + 1]\)]]; 

            x = Floor[x/100]]; StringJoin[z]];\)\)
alph1[n_] := num2txt1[n];  
    num1[n_] := txt2num1[n];
alph0[n_] := num2txt0[n];  num0[n_] := txt2num0[n]; 
    txt2num[plaintext_] := txt2num1[plaintext];  
    num2text[n_] := num2txt1[n];  num2text0[n_] := num2txt0[n];

naive = 152415787501905985701881832150835089037858868621211004433; 
    cnaive = 141077461765569500241199505617854673388398574333341423525;
sigpairm1 = 
        418726553997094258577980055061305150940547956;
sigpairs1 = 
        749142649641548101520133634736865752883277237;
sigpairm2 = 14823765232498712344512418717130930;
sigpairs2 = 43176121628465441340112418672065063;
signa = 171024704183616109700818066925197841516671277;
signb = 839073542734369359260871355939062622747633109;
sigpb = 98763457697834568934613;
sigqb = 8495789457893457345793;

n1 = 8834884587090814646372459890377418962766907;

\(\(addell[p1_, p2_, a_, b_, n_] := 
        Module[{z, m, x3, y3, p3, z1}, 
		z = 0; z1 = 1; 
	
          If[p1 == {"infinity", "infinity"}, \ p3 = p2; 
            z = 1, " "]; 
\ \ If[z == 1, " ", 
            If[p2 == {"infinity", "infinity"}, p3 = p1; 
              z = 1, " "]]; 
	
          If[z == 1, " ", 
            If[p1[\([1]\)] == p2[\([1]\)] && 
                p1[\([2]\)] == p2[\([2]\)] == 0, \ 
              p3 = {"infinity", "infinity"}; 
              z = 1, " "]]; 
		If[z == 1, " ", 
            If[p1[\([1]\)] == p2[\([1]\)] && p1[\([2]\)] != p2[\([2]\)], 
              p3 = {"infinity", "infinity"}; 
              z = 1, " "]]; 
		If[z == 1, " ", 
            If[p1 == p2 && GCD[p1[\([2]\)], n] != 1 && 
                GCD[p1[\([2]\)], n] != n, z = 1; 
              z1 = GCD[p1[\([2]\)], n], " "]]; 
	\ If[z == 1, " ", 
            If[p1 == p2, \ 
              m = Mod[\((3*p1[\([1]\)]^2 + a)\)*
                    PowerMod[2*p1[\([2]\)], \(-1\), n], n]; z = 1; 
              x3 = m^2 - p1[\([1]\)] - p2[\([1]\)]; 
              y3 = m*\((p1[\([1]\)] - x3)\) - 
                  p1[\([2]\)]; 
	\ \ \ \ \ \ \ 	p3 = 
                Mod[{x3, y3}, n], " "]]; 
				If[z == 1, " ", 
            If[GCD[p2[\([1]\)] - p1[\([1]\)], n] != 1, z = 1; 
              z1 = GCD[p2[\([1]\)] - p1[\([1]\)], n], " "]]; 
				If[
            z == 1, " ", \ 
            m = Mod[\((p2[\([2]\)] - 
									p1[\([2]\)])\)*
                  PowerMod[p2[\([1]\)] - p1[\([1]\)], \(-1\), n], n]; 
            x3 = m^2 - p1[\([1]\)] - p2[\([1]\)]; 
            y3 = m*\((p1[\([1]\)] - x3)\) - p1[\([2]\)]; 
		p3 = 
              Mod[{x3, y3}, n]]; 
          If[z1 == 1, p3, {"factor=", z1}]];\)\)
\(multsell[p1_, m_, a_, b_, n_] := 
      Module[{z}, z = {1, \ p1}; 
        For[i = 1, 
          i < m && \(z[\([Length[
                      z]]\)]\)[\([1]\)] != "factor=", 
\(i++\), z = Append[z, i + 1]; 
          z = Append[z, addell[p1, z[\([Length[z] - 1]\)], a, b, n]]]; 
        z]\)

\(multell[p_, m_, a_, b_, n_] := 
      Module[{s, l, v, m1, r}, 
        l = Ceiling[
            Log[2. , m] + 
              10^\((\(-1\))\)]; 
s = {"infinity", "infinity"}; r = {"infinity", "infinity"}; m1 = m; 
        For[i = 1, 
          i < l + 1 && 
            r[[1]] ≠ "factor=", \(i++\), 
v = Floor[m1/2^\((l - i)\)]; 
          If[
v == 1, 
            r = If[s[\([1]\)] == "factor=", s, addell[s, p, a, b, n]]; 
            m1 = m1 - 2^\((l - i)\), r = s]; s = addell[r, r, a, b, n]]; 
        r]\)

cards = {200514,  10010311,   1721050514,   11091407,  
          10305};

<< DiscreteMath`Permutations`;

khide := 2*Random[Integer, {100, 1000000}] + 1; 
    shuffle := Module[{per}, per = RandomPermutation[5]; 
        Table[PowerMod[cards[[per[[n]]]], k, 24691313099], {n, 
            5}]];

advise[v_] := 
      Module[{t, u}, t = PowerMod[v, (24691313099 - 1)/2, 24691313099]; 
        u = (t[[1]] + 2*t[[2]] + 3*t[[3]] + 4*t[[4]] + 
                5*t[[5]] - 15)/24691313097]; u;

reveal[v_] := 
        Module[{nu}, 
          nu = PowerMod[v, PowerMod[k, -1, 24691313098], 
              24691313099]; 
{a[nu[[1]]], 
            a[nu[[2]]], a[nu[[3]]], a[nu[[4]]], 
            a[nu[[5]]]}];

golay = {{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 
            0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 
            1, 1, 1, 0, 0, 0, 1}, {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 
            0, 1, 1, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 
            0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 1, 0, 0, 0, 
            0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0}, {0, 0, 0, 0, 0, 
            1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1}, {0, 0, 
            0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 
            1}, {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 
            1, 1, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 
            0, 0, 1, 0, 1, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 
            1, 1, 1, 0, 0, 0, 1, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
            0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
golayb = {{1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0}, {1, 0, 1, 1, 0, 1, 1, 
            1, 0, 0, 0, 1}, {1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0}, {1, 0, 1, 
            0, 1, 1, 0, 1, 1, 1, 0, 0}, {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 
            0}, {1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1}, {1, 1, 0, 0, 0, 1, 0, 
            1, 1, 0, 1, 1}, {1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 
            1, 0, 0, 0, 1, 0, 1, 1, 0}, {1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 
            1}, {1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1}, {0, 1, 1, 1, 1, 1, 1, 
            1, 1, 1, 1, 1}};
hammingpc = {{0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0}, {1, 1, 1, 
            0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0}, {0, 1, 1, 1, 0, 1, 1, 0, 0, 
            1, 1, 0, 0, 1, 0}, {1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 
            1}};