第一章序曲

pages1 - 9

1.2.一個簡單的例子

\(\(key = {"A" -> "N", "B" -> "U", "C" -> "M", "D" -> "B", "E" -> "E", "F" -> "R", "G" -> "T", "H" -> "H", "I" -> "O", "J" -> "Y", "K" -> "A", "L" -> "C", "M" -> "D", "N" -> "F", "O" -> "G", "P" -> "I", "Q" -> "J", "R" -> "K", "S" -> "L", "T" -> "P", "U" -> "Q", "V" -> "S", "W" -> "V", "X" -> "W", "Y" -> "X", "Z" -> "Z"};\)\)
encrypt[plaintext_] := StringReplace[plaintext, key];

encrypt["SEND MONEY"]

1.4.來自數論的靈感

p = 23; q = 47; n = p*q

abc = " abcdefghijklmnopqrstuvwxyz";
\(\(no = "000102030405060708091011121314151617181920212223242526";\)\)
digitalize = 
        Table[StringTake[abc, {i}] -> 
            StringTake[no, {2*i - 1, 2*i}], {i, 1, 27}];
alphabetize = 
        Table[StringTake[no, {2*i - 1, 2*i}] -> 
            StringTake[abc, {i}], {i, 1, 27}];
Q[plaintext_] := StringReplace[plaintext, digitalize];
Qd[plaintext_] := 
        ToExpression[Q[plaintext]];
A[digit_] := StringReplace[digit, alphabetize];

Q["send money"] <> "0"

m = 
      Table[StringTake[Q["send money"] <> "0", {i, i + 2}], {i, 1, 
            21, 3}] // ToExpression

e = 3; c = PowerMod[m, e, n]

b = LCM[p - 1, q - 1]
d = PowerMod[e, -1, b]

PowerMod[c, d, n]
PowerMod[c, d, n] == m

A["19051404001315140525"]

1.5.計算之複雜度的分析

Log[2, 10^200] // N

1.6.誰還管生生世世夜夜朝朝

Sqrt[10^200]/(10^6*60*60*24*365.25)