Lecture Notes on The Code Book by Simon Singh

... for the class
Codes, codemakers, codebreakers: an introduction to cryptography.
[Stuff inside square brackets is not in Singh's text.]




extra stuff

  • sequential homophonic cipher
  • black chamber 48bce
  • black chamber 900
  • black chamber 1500
  • black chamber 1599
  • black chamber 1918
  • black chamber 1860
  • black chamber 1918
  • black chamber 1942
  • black chamber: one-time-pad evolution

  • context for reading this book


    Introduction to The Code Book by Simon Singh


    Cipher of Mary Queen of Scots


    Evolution of Secret Writing

     a b c d e f g h i j k l m n o p q r s t u v w x y z
     1 0 2 1 6 1 0 2 2 0 0 1 1 3 3 1 0 3 4 3 0 0 0 1 0 0
    
    how many rearrangements of a 1-2-1-6-2-2-1-1-3-3-1-3-4-3-1 multiset?
    35! / (1! * 2! * 1! * 6! * 2! * 2! * 1! * 1! * 3! * 3! * 1! * 3! * 4! * 3! * 1! )

    encryption/decryption


    transposition cipher

    s    e    n    d    m    o    r    e
    \t   \r   \o   \o   \p   \s   \t   \o
     \s   \o   \u   \t   \h   \e   \r   \n
      \f   \l   \a   \n   \k   \x   \q   \i
    
    stsferolnouadotnmphkosexrtuqeoni
    
    r    i    f    n    e    i    h    r
    \   /\   /\   /\   /\   /\   /\   /\
     \a/  \l/  \e/  \c/  \c/  \p/  \e/  \
    
    rifneihraleccpe 
    

    substitution cipher

    abcdefghijklmnopqrstuvwxyz 3-shift Caesar cipher
    DEFGHIJKLMNOPQRSTUVWXYZABC 3-VKLIW fDHVDU FLSKHU
    
    abcdefghijklmnopqrstuvwxyz how secure is this?
    MARYQUENOFSCTVWXZBDGHIJKLP NWJ DQRHBQ OD GNOD?
    

    Arab cryptanalysts: linguistics, statistics, religious devotion


    cryptanalysing a ciphertext

    UANQ PILDNDC, PF HNC OANBS (T CNLB) SNS TQM THIVU PF OLFJUICLTJAF OBTQQ. N QTNS UATU FIV TBB PVQU SI T UANLUF YILS QUILF YNUAIVU VQNDC T JTLUNOVBTLBF OIPPID YLNUNDC QFPHIB (N'P AIJNDC UATU FIV CLTQJ YATU N'P QTFNDC). QI PF HNC OANBS TDS PF QPTBB OANBS (TBQI T CNLB) QUTLU UANQ UTQM LNCAU TYTF.

    English history


    renaissance in the west


    Babington plot


    le chiffre indéchiffrable

    W H I T E W H I T E W H I T E W H I T E W H I
    d i v e r t t r o o p s t o e a s t r i d g e
    Z P D X V P A Z H S L Z B H I W Z B K M Z N M
    
    abcdefghijklmnopqrstuvwxyz
    bcdefghijklmnopqrstuvwxyza
    cdefghijklmnopqrstuvwxyzab
    defghijklmnopqrstuvwxyzabc
    efghijklmnopqrstuvwxyzabcd
    fghijklmnopqrstuvwxyzabcde
    ghijklmnopqrstuvwxyzabcdef
    hijklmnopqrstuvwxyzabcdefg
    ijklmnopqrstuvwxyzabcdefgh
    jklmnopqrstuvwxyzabcdefghi
    klmnopqrstuvwxyzabcdefghij
    lmnopqrstuvwxyzabcdefghijk
    mnopqrstuvwxyzabcdefghijkl
    nopqrstuvwxyzabcdefghijklm
    opqrstuvwxyzabcdefghijklmn
    pqrstuvwxyzabcdefghijklmno
    qrstuvwxyzabcdefghijklmnop
    rstuvwxyzabcdefghijklmnopq
    stuvwxyzabcdefghijklmnopqr
    tuvwxyzabcdefghijklmnopqrs
    uvwxyzabcdefghijklmnopqrst
    vwxyzabcdefghijklmnopqrstu
    wxyzabcdefghijklmnopqrstuv
    xyzabcdefghijklmnopqrstuvw
    yzabcdefghijklmnopqrstuvwx
    zabcdefghijklmnopqrstuvwxy
    
    cj = ( pj + kj mod κ ) mod α

    shunning Vigenére to Man in Iron Mask

    a     09 12 33 47 53 67 78 92
    b     48 81
    c     13 41 62
    d     01 03 45 79
    e     14 16 24 44 46 55 57 64 74 82 87 98
    f     10 31
    ...   ...
    x     28
    y     21 52
    z     02
    

    Antoine/Bonaventure Rossignol


    black chambers


    Babbage v Vigenère


    agony columns to buried treasure


    Beale saga


    mechanisation of secrecy


    Polybius

       1   2   3   4   5
    1  a   b   c   d   e
    2  f   g   h  i/j  k
    3  l   m   n   o   p
    4  q   r   s   t   u
    5  v   w   x   y   z
    
    23 34 52 24 43 44 23 15 35 34 31 54 12 
    24 45 43 22 42 24 14 45 43 15 21 45 31 
    24 33 44 15 31 15 22 42 11 35 23 54  ?
    
       1   2   3   4   5   6
    1  a   b   c   d   e   f
    2  g   h   i   j   k   l
    3  m   n   o   p   q   r
    4  s   t   u   v   w   x
    5  y   z   0   1   2   3
    6  4   5   6   7   8   9
    

    Playfair cipher (Appendix E)

       C   H   A   R   L
       E   S   B   D   F
       G  I/J  K   M   N
       O   P   Q   T   U
       V   W   X   Y   Z
    
    plaintext:   retreat left          ??????????
    
                 re tr ea tl ef tx     ?? ?? ?? ?? ??
    
    ciphertext:  CD YD BC UR SE QY     BC DW UP PF GC
    
    LP YN UG DZ UC PA DS OT MS AE SE CU DH NK BU UC ES TG YD
    

    ADFGVX cipher (Appendix F)     . _     _ . .     . . _ .     _ _ .     . . . _     _ . . _

        A D F G V X
    A   8 P 3 D 1 N
    D   L T 4 O A H
    F   7 K B C 5 Z
    G   J U 6 W G M
    V   X S V I R 2
    X   9 E Y 0 F Q
    
    keyword: CUBE       
    
    c  r  a  c  k  e  d  b  y  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?
    
    FG VV DV FG FD XD AG FF XF ** ** ** ** ** ** ** ** ** ** ** ** ** **
    
    C U B E  => B          C           E          U
    
    F G V V      VFXF*******FDFAX*******VGDF*******GVDGF*******
    D V F G 
    F D X D 
    A G F F 
    X F * *
    * * * * 
    * * * *
    * * * *
    * * * *
    * * * *
    * * * *
    * *
    

    ADFGVX cryptanalysis

    v d g g f x x g g d d v d f g g d g g v d d f d x d d v v v d d f x a g a a a x
    v d d d
    d v d d
    g d f f
    g f d x 
    f g x a
    x g d g
    x d d a
    g g v a
    g g v a
    d v v x
    
    grid: see Appendix F    keysize: 4 
    VFXFGDGVDAVFDFAXXVXAVVAVGDFVGVDVXGGVDGFDVDDGFX
    ----------------------------------------------
    perm? was 1234?  e.g. keyword ARTY
    12 chars     12 chars     11 chars    11 chars
    VFXFGDGVDAVF DFAXXVXAVVAV GDFVGVDVXGG VDGFDVDDGFX
    
    VDGVFFDD ... => s g b t ...   :(
    ----------------------------------------------
    perm? was 1243?  e.g. keyword ARTS
    12 chars     12 chars     11 chars    11 chars
    VFXFGDGVDAVF DFAXXVXAVVAV GDFVGVDVXGG VDGFDVDDGFX
    
    VDVGFFDD ... => s i b t ...   :(
    ----------------------------------------------
    perm? ...  
                                   :(
    ----------------------------------------------
    perm? .... was 3142? e.g. keyword CUBE
    11 chars    12 chars     11 chars    12 chars
    VFXFGDGVDAV FDFAXXVXAVVA VGDFVGVDVXG GVDGFDVDDGFX
    
    FGVVDVFG ... => c r a c ...   :)
    

    Zimmermann affair


    holy grail: 1-time pad


    evolution of 1-time pad

    D D D D D D D D D D D D
    c a e s a r c i p h e r 
    F D H V D U F L S K H U 
    abcdefghijklmnopqrstuvwxyz
    DEFGHIJKLMNOPQRSTUVWXYZABC
    
    abcdefghijklmnopqrstuvwxyz
    BLIZARDWNGHJKMOPQSTUVXYCEF
    k e y p h r a s e s u b s t i t u t i o n c i p h e r 
    H A E P W S B T A T V L T U N U V U N O M I N P W A S
    
    S E C R E T S E C R E T S E 
    v i g e n e r e c i p h e r 
    N M I V R X J I E Z T A W V 
    
    A N H I S T O R I C A L I N T R 
    r u n n i n g k e y c i p h e r 
    R H U V A G U B M A C T X U X I 
    
    Q T X P L K G G U R E M P D W X 
    o n e t i m e p a d c i p h e r 
    E G B I T W K V U U G U E K A O 
    

    equiprobable keys, equiprobable plaintexts

    ?  ?  ?  ?  ?  ?
    ?  ?  ?  ?  ?  ?
    C  T  F  Q  Q  R
    
    C-H  T-E  F-L  Q-P  Q-M  R-E    C-G  T-O  F-A  Q-W  Q-A  R-Y
     h    e    l    p    m    e      g    o    a    w    a    y
     C    T    F    Q    Q    R      C    T    F    Q    Q    R  
    

    reuse of 1-time pad: appendix G


    cipher machines -- cipher discs to Enigma


    cracking Enigma


     V E C J I B    rotors 123, start DDN
     E W O P F A
     K D A L Y T    1-4:
     L C V T E O    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
     B A H Q D Z                                              J
     J Y S I B Y
     T I Q W V P
     Q X E Y R Q
     P G Y F A V    2-5:
     F Q P A L R    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
     C R M U Q N            I                                          
     D U R C J M
     Z Z K N U L
     Y O U M W K
     X N B S S D    3-6:
     I T J B T G    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
     H J G E K H        B
     U K L V H J
     W V F O O U
     G P X D P C
     R L N K M S
     A S D R G I
     S B Z G N X
     O H T Z Z W
     N F I H C F
     M M W X X E
    

    Poles pass baton ...


    geese that never cackled


    Alan Turing


    Rejewski and Enigma


    Turing and Enigma


    Bletchley Park


    Turing's crib circuit method (assuming no ring)

    deduce plugboard settings


    kidnapping codebooks


    anonymous cryptanalysts


    Ch 5: language barrier


    Navajo code talkers


    decipher lost languages


    deciphering linear B


    Alice and Bob go public


    God rewards fools


    birth of public-key cryptography


    prime suspects


    alternative history of public-key cryptography


    binary numbers


    Diffie-Hellman-Merkle key exchange


    DHM correctness


    DHM efficiency

    DHM security

  • how hard to "undo" exponentition, i.e. find e s.t. a**e %n = x ?
  • discrete logarithm problem
  • as far as we know: slow ...   try each possible exponent

    DHM example

    p            = 613144603035200518605071627722399281527
    base         = 347449578131074797459449734586666998031
    alice_secret = 474140564715023867271727810192114419457
    bob_secret   = 556327197178837163583577967104054021837
    
    alice_sends  = pow(base,        alice_secret, p)
    bob_sends    = pow(base,        bob_secret,   p)
    alice_key    = pow(bob_sends,   alice_secret, p)
    bob_key      = pow(alice_sends, bob_secret,   p)
    
    Alice,Bob probable prime 613144603035200518605071627722399281527
    Alice,Bob base           347449578131074797459449734586666998031
    Alice sends Bob          344627486120828843474388906075377334410
    Bob   sends Alice        409706635860222822429885047531176332371
    Alice creates key        450786317947341275948138905696766128062
    Bob   creates key        450786317947341275948138905696766128062
    

    Alice and Bob find a large prime how?


    Fermat's Little Theorem


    probabilistic primality test


    Euler's Totient Generalization


    Euclid's Greatest Common Divisor

       Euclid gcd: compute gcd(a,b), a= 60534384   b= 35717371
       gcd is last non-zero remainder
    60534384 - 35717371 * 1 = 24817013
    35717371 - 24817013 * 1 = 10900358
    24817013 - 10900358 * 2 = 3016297
    10900358 - 3016297 * 3 = 1851467
    3016297 - 1851467 * 1 = 1164830
    1851467 - 1164830 * 1 = 686637
    1164830 - 686637 * 1 = 478193
    686637 - 478193 * 1 = 208444
    478193 - 208444 * 2 = 61305
    208444 - 61305 * 3 = 24529
    61305 - 24529 * 2 = 12247
    24529 - 12247 * 2 = 35
    12247 - 35 * 349 = 32
    35 - 32 * 1 = 3
    32 - 3 * 10 = 2
    3 - 2 * 1 = 1
    2 - 1 * 2 = 0
    
       extension: express gcd as linear combination of a,b
    1  =  3 * 1  +  2 * -1   ... substitute: 2 = 32 - 3 * 10
    1  =  32 * -1  +  3 * 11   ... substitute: 3 = 35 - 32 * 1
    1  =  35 * 11  +  32 * -12   ... substitute: 32 = 12247 - 35 * 349
    1  =  12247 * -12  +  35 * 4199   ...
    1  =  24529 * 4199  +  12247 * -8410  ...
    1  =  61305 * -8410  +  24529 * 21019  ...
    1  =  208444 * 21019  +  61305 * -71467  ...
    1  =  478193 * -71467  +  208444 * 163953  ...
    1  =  686637 * 163953  +  478193 * -235420  ...
    1  =  1164830 * -235420  +  686637 * 399373  ...
    1  =  1851467 * 399373  +  1164830 * -634793  ...
    1  =  3016297 * -634793  +  1851467 * 1034166  ...
    1  =  10900358 * 1034166  +  3016297 * -3737291  ...
    1  =  24817013 * -3737291  +  10900358 * 8508748  ...
    1  =  35717371 * 8508748  +  24817013 * -12246039  ...
    1  =  60534384 * -12246039  +  35717371 * 20754787
    

    RSA


    pretty good privacy


    pgp features


    DH digital signature


    simple signature example (use RSA, ignore hashing)


    pgp protocol (roughly)


    encryption for the masses ... or not


    a quantum leap into the future


    future of cryptanalysis


    quantum mechanics


    quantum money


    quantum cryptrography


    Bennett-Brassard qc protocol


    Bennett-Brassard qc security


    quantum computers


    so-called bible code


    some linux crypto commands

    substitute x with a, y with b, z with c: 
     tr [xyz] [abc] < infile
    
    Caesar cipher
      tr "a-zA-Z" "d-za-cD-ZA-C" < infile
    
    remove all characters except "xyz":
     tr -cd "xyz" < infile
    
    character counts:
      fold -w1 < infile | sort | uniq -c | sort -rn
    
    print all 6-letter words ending in "ana":
      egrep "^[a-z]{3}ana$" /usr/share/dict/words
    

    troubleshooting


    some 20C discrete math


    index of coincidence

    { a,a,a,a,b,b,c,d,d,d,e,e,e,e,e} ? 
    
    I_c  =  (4*3 + 2*1 +  1*0 + 3*2 + 5*4) / (15*14)
         =  (12  +  2  +   0  +  6  + 20 ) /  210 
         =   0.19...
    
    { a,a,a,b,b,b,c,c,c,d,d,d,e,e,e } ? 
    
    I_c  =  (3*2 + 3*2 +  3*2 + 3*2 + 3*2) / (15*14)
         =  ( 6  +  6  +   6  +  6  +  6 ) /  210 
         =   0.14...
    
    I_c  =   ( f_1*(f_1 - 1) + f_2*(f_2 - 1) + ... + f_c*(f_c - 1) / n*(n-1)
    
    if n is large,  (f_j - 1) / (n - 1)  ≈  f_j / n   =   p_j,  and so
    
    I_c  ≈ p_1^2 + p_2^2 + ... + p_c^2
    

    index of mutal coincidence

    { a a a a      b b     c  d d d  e e e e e } and
    { a a a a a  b b b b  c c   d      e e e   }  ?
    
    I_mc = (4*5 + 2*4 + 1*2 +  3*1 + 5*3) / (15*15) = 
         =  48/225 = 0.21...
    
    { a a a a   b b   c   d d d   e e e e e } and
    { a a a a   b b   c   d d d   e e e e e }  ?
    
    I_mc = (4*4 + 2*2 + 1*1 +  3*3 + 5*5) / (15*15) = 
         =  55/225 = 0.24...
    

    Friedman IC and IMC method to crack Vigenère cipher

    fake example: consider 5 character alphabet with typical frequencies below, and ciphertext substring frequencies (a bbb ccccc dddd ee). which shift gives best IMC?
     a    b    c    d    e
    .27  .13  .07  .20  .33
    
    shift 0    a->a    (a bbb ccccc dddd ee)
    ((1*.27) + (3*.13) + (5*.07) + (4*.2) + (2*.33))/15 = .165
    
    shift 1    a->b    (aa b ccc ddddd eeee)
    ((2*.27) + (1*.13) + (3*.07) + (5*.2) + (4*.33))/15 = .213
    
    shift 2    a->c    (aaaa bb c ddd eeeee)
    ((4*.27) + (2*.13) + (1*.07) + (3*.2) + (5*.33))/15 = .244
    
    shift 3    a->d    (aaaaa bbbb cc d eee)
    ((5*.27) + (4*.13) + (2*.07) + (1*.2) + (3*.33))/15 = .213
    
    shift 4    a->e    (aaa bbbbb cccc dd e)
    ((3*.27) + (5*.13) + (4*.07) + (2*.2) + (1*.33))/15 = .165
    

    IC and Vigenère cryptanalysis

       a       b       c     ...      z
     .081    .019    .028           .001
     .0066 + .0004 + .0008 + ...  + .0000  =  .065...
    
    SAABTFWFTBJVAKLGCZSRVVAHCMBEHNQIFIAWNA
    FGZMIOFUIZPRKCZUSGZFCQSGFVRFWFSFGNFVRV
    WQGAGBIWYDAAIAVIEHUWLASFLWPOLQWGQNFAUB
    TXWDHUWEUZYTMFVNLEMGJSTFYRDTK
    
    keysize 1 ?
      substring S A A B T ...
      I_c = .050
    
    keysize 2 ?
      substring S A T W T ...
      substring A B F F B ...
      avg I_c = .053
    
    keysize 3 ?
      substring S B W B A ...
      substring A T F J K ...
      substring A F T V L ...
      avg I_c = .054
    
    keysize 4 ?
      substring S T B K Z ...
      substring A F J L S ...
      substring A W V G R ...
      substring B F A C V ...
      avg I_c = .046
    
    keysize 5 ?
      substring S F J G V ...
      substring A W V C V ...
      substring A F A Z A ...
      substring B T K S H ...
      substring T B L R C ...
      avg I_c = .070
    
    keysize 6 ?
      substring S W A S C ...
      substring A F K R M ...
      substring A T L V B ...
      substring B B G V E ...
      substring T J C A H ...
      substring F V Z H N ...
      avg I_c = .043
    

    counting plugboard pairings


    cycle decompositions (for Rejewksi signatures)

  • how many cycle decompositions of a 26-permutation ?
  • how many ways to sum to 26 ?
  • how many partitions of n=26 ?
     n   p(n)
     1    1       1
     2    2       2 1+1
     3    3       3 2+1 1+1+1
     4    5       4 3+1 2+2 2+1+1 1+1+1+1
     5    7       5 4+1 3+2 3+1+1 2+2+1 2+1+1+1 1+1+1+1+1
     6   11       6 5+1 4+2 4+1+1 3+3 3+2+1 3+1+1+1 2+2+2 2+2+1+1 2+1+1+1+1 1+1+1+1+1+1
      
    ...
        
    26  2436
    

    prime factorization


    recognizing the running key cipher

    #!/usr/bin/env python
    # show single letter frequencies of running key cipher,
    # assuming both key and ptext independently uniformly sampled from 
    # typical English letter single letter frequencies
    import string
    L = [ # English letter frequencies
     8.167, 1.492, 2.782, 4.253, 12.702, 2.228, 2.015, 6.094, 6.966, 0.153,
     0.772, 4.025, 2.406, 6.749,  7.507, 1.929, 0.095, 5.987, 6.327, 9.056,
     2.758, 0.978, 2.360, 0.150,  1.974, 0.074 ]
    
    def printAlphabet():
      alphabet = string.ascii_lowercase
      for letter in alphabet:
        print ' '+letter,
      print ''
    
    def showAsPerCentRatios(A):
      for j in range(len(A)):
        print "%2d" % int(round (100.0*A[j]/(1.0*sum(A)))),
      print ''
    
    def runningCipherFreqs(L):
      M = [] # running cipher frequencies
      n = len(L)
      # compute M
      for j in range(n):
        s = 0.0
        for k in range(n):
          s += 1.0*L[k]*L[(j-k)%n] # ptxt k + key (j-k) = ctxt j
        M.append(s/sum(L))
      return M
    
    printAlphabet()
    showAsPerCentRatios(L)
    showAsPerCentRatios(runningCipherFreqs(L))
    ---------------
    python < run_ciph_freq.py 
     a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z 
     8  1  3  4 13  2  2  6  7  0  1  4  2  7  8  2  0  6  6  9  3  1  2  0  2  0 
     5  3  3  3  5  4  4  5  5  3  4  5  4  3  3  4  3  4  4  4  3  5  5  4  3  4 
    

    sequential homophonic cipher

    s*iqq4epdwvjg3oh2#*3z,5e'9icmsw3qtg0r*s/t9%+mes%bvpwhxlat*&1ke'
    wi3g.h26uvu4'-zk*s9+qei5rwxjh3,)ba't.*%clq)u0e(4#m,doksg&k1/2uib(
    6w5paxu3.5r9sz-t*hc0jenomx2l4s1#zgk93wcm-'3jid,8ubh0uyo'6g&59(*d2a/&
    r.+4kzi,t1p%beh(cla3m0q-k6gdkj#.kw2r4/&*'xzo1$uyl9(p,dm5bi3aec
    &u+%gnwh(9d+*'xi.e#36w/%4&0-h(ju2r3*po+m'e
    zlgd9&%wi5m(*n,#qdghvu+e/1'b9c3-i&m(0djk%g2z+a.%&4c6wh0r,(b*
    de'xwi59&*)ou2zlpa.sm+4(%1hvgcd)#,ex06w2'-yj9izbf3a.5&*8ue/c4p
    okwsm+,g09(dby*#e2axk/1szr.swmh%*'5)qe&3wp34+qy,#3bycg)%a3/.4$
    -j!9ivm0(t*q2lpouv6etg+x,#hbd&1k/a.5(w'xd%9s4*ken-pmz,#b&j/cok
    0raswp(l6.i2r4n,vbz*cg1heds9vl0)a&uyy-(.5md&3w'2j#*z+4e(c
    xtw/kgd6io0p,b&1k*hqsev'92u5aw#.z-)4(,biha*/cr.t4d0,p'bf2#asmzq
    tl./4kjpcsou%0#g,&2eix(wh5t6b/a*p.d1s4s9&,#e)+bk/wsa)um%xg'v(
    z.i*hc45xup9'vduss,#)q0rbkuvm2gna&k/-s3lep+.(zji5udcwhxk4n,#s*q
    )bkou'59ixa.5064)/m&2%qye+s,zc1)u02rbtl-%ag(+whxt9z6cr.
    4f3,y0mj'ok2lgdtb&zapiy19hc*'5e%mi.-k6w#xtrg04),*3ljh26b
    (ae3owdz9&31n./45tmcr*x,'(bui5apv#-t0ljk26.dt4,zsq/c+b&osu3r
    ypg!ax)q0l.61#293u%zu/m(cd-k4hv+e'50r,&lpu)6b#ajk2.iwzc*gh(0r4
    l,9v62okkmkzba'1/ct.i0qk4,2ehxk-psdw'*%sj&zgsybiac#e)+.3oyy934
    )u/0r,hm'v2lbwgpt9z6mc(k#*v/ei3a
    
    1117 characters  49 different  (each datum is count)
       224 2202727271932203017292427172829302220 2273030282732 327272818342027 8182418203121301831221528
       ! # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z
    !  . . . . . . . . . . . . . . . . . . . . . . 1 1 . . . . . . . . . . . . . . . . . . . . . . . . .
    #  . . . . . . . 1 3 . 1 1 2 . . . 1 2 . . . . . 2 1 . . 3 . 1 1 . . . . 1 . . . 1 . 1 . . . . 1 . 1
    $  . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . .
    %  . . . . 1 . . . 1 1 . . . . 1 1 . . 1 . . . 1 2 2 1 . . . 2 . . . . . 1 . . . 1 . 1 . . . 1 1 . 1
    &  . . . 1 . . . . 3 . 1 . . . 1 3 2 3 1 1 . . . . . . . . . . . . 1 2 1 1 . 1 . . 1 . . 2 . . . . 2
    '  . . . . . . 1 . 1 . . 2 . . . 1 1 1 . 4 1 . 2 . 2 . . 1 . . . . . . . . . 1 . . . . 1 . 3 1 4 . .
    (  . . . 1 . . . . 2 1 1 . 1 . 2 . . . 1 . 1 . 1 1 2 3 1 . . . . . 1 1 1 . . . 1 . . . 1 . . 2 . . 2
    )  . 1 . 1 . . . . . 2 1 . . 1 . . . . 1 . 1 . . 1 2 . . . . . . . . . . . . 1 . 3 . . . 4 . . . . .
    *  . 1 . 2 1 4 . 1 . . . . . 1 . . . 2 . . . 1 . . . 1 2 . . 1 3 1 . 1 . . 1 . 2 2 . 2 . . 1 . 1 . 1
    +  . . . 1 . . . . 1 . 1 . 2 . . . . . 3 . . . . 1 2 . . 2 . . . . . . . 2 . . . 2 . 1 . . . 1 1 . .
    ,  . 7 . . 2 1 1 1 1 . . . . . . . 1 . . 1 . 1 1 . 2 . 2 1 . 1 1 . . . . . . . 1 . . . 1 . 1 . . 1 2
    -  . . . 1 . 1 1 1 . . . . . . . . . . . . . . . . . . . . . . 1 1 1 3 . . . . 2 . . 1 2 . . . . 1 1
    .  . . . 1 . . 1 . 1 1 . 1 . 2 . . . 1 2 5 1 . . . . . 2 1 . . 1 4 . 1 . . . . . . . 2 1 . . . . . 1
    /  . . . 1 2 . . . . . . 1 1 . 1 2 1 . 2 . . . . 2 . 5 . 1 . . . . . 1 . 2 . . . . . . 1 . . 1 . . .
    0  . 1 . . . . 1 1 . . 1 1 . . . . 1 . 1 . 2 . 1 . . . 1 1 . . . . 1 . 2 1 . . 1 2 7 . . 1 . . . . .
    1  . 2 1 . . 1 . 1 . . . . . 2 . . . . . . . . 1 . . . . . . . 2 . . 3 . . 1 . 1 . . 2 . . . . . . .
    2  . 2 . 1 . 1 . . . . . . 1 . . . . . . . 3 . 1 2 . . . 2 . 1 . . 1 . 4 . . 1 . . 4 . . 2 . . . . 2
    3  . . . . . . . . 1 . 2 1 1 1 . 1 . . 2 . 1 . . 3 1 . . . . 1 . . 1 . 2 1 . 3 . 1 1 . . 1 . 3 . . 1
    4  . 1 1 . 1 1 2 3 1 1 2 . . 1 . . . . . 2 . . . . . 1 1 2 1 . 1 . . 2 1 . 2 . 1 . . 2 . . . . . . .
    5  . . . . 1 . 1 1 . . . . . . 2 . . . . . . . 3 2 1 . . 2 . . . . . . . 2 . . 1 . 2 . 2 1 . . 1 . .
    6  . . . . . . . . . . . . 2 . . 1 1 . 1 . . . . . 3 1 . 1 . 2 . 1 . . . 1 . . . . . . . 1 . 5 . . .
    8  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 . . . . .
    9  . . . 1 4 1 3 . . 1 . . . . . . 1 3 . . . . . . . 1 1 . . . 1 4 . . . . . . . . . 2 . . 2 . . . 2
    a  . . . . 2 2 . 1 2 . . . 5 1 . . . 2 . . . . . . . 1 . 2 . 1 . . 1 . . . . . 2 . . 2 1 . . 1 3 . .
    b  . 1 . . 4 . 2 . 1 . . . . 1 . . . . . . . . 1 2 . . 1 1 2 . 1 3 . 3 . . . . . . . . 1 1 1 1 . 2 1
    c  . 1 . . 1 . 1 . 2 1 . . . . 1 1 . 1 2 . 1 . . . . . 2 . . 2 . . . . 2 2 . 1 . . 3 1 1 . . 1 1 . .
    d  . . . 1 2 . . 1 . 1 1 1 . . 1 1 1 . . . 1 . 1 . 1 1 . 1 . 1 . . 1 1 . 1 . 1 . . . 1 2 1 . 2 . . 1
    e  . 1 . 1 1 4 2 2 . 1 . . . 2 . . 1 1 . . . . . . . 1 1 . . . 2 3 . . . . 2 . 2 . . 1 1 . 1 . 1 . 1
    f  . . . . . . . . . . . . . . . . 1 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    g  1 . . . 2 1 1 1 . 1 1 . 1 . 3 1 1 1 . . . . . . . 1 4 . . . 2 . . 1 . . 2 . 1 . . 1 . . . . . . .
    h  . . . 1 . . 4 . . . . . . . 2 . 3 1 . 1 . . . 1 1 3 . 1 . . . . . . . 1 . . . 1 . . . . 3 . 4 . .
    i  . . . . 1 . . . 1 . 1 . 2 . 1 . 1 3 . 5 . . . 1 1 1 1 . . . 1 . . . . . . 1 . 1 . . . . 1 1 2 1 1
    j  1 2 . . 1 1 . . . . . . . 1 . . . . . . . . 1 . . . . 1 . 1 2 2 . 3 . . . . 1 . . . . 1 . . . . .
    k  . 1 . 1 . . . . 2 . . 1 . 4 1 1 3 . 3 . 2 . 1 . . . . 2 . 1 . . 2 1 . 1 . 1 . . . 1 . 1 . 2 . . 2
    l  . . . . . . . . . . 1 1 2 . 1 . . . 1 . 1 . 1 2 1 . . 1 . 2 . . 2 . . . . . 3 1 . . . . . . . . .
    m  . . . 1 1 2 3 . . 2 1 1 . . 2 . 1 . . 1 . . . . . 2 1 1 . . 1 1 1 1 . . . . . . . 1 . . . . 1 . 2
    n  . . . . . . . . . . 3 1 1 . . . . . . . . . . 1 . . . . . . . . . . . . . 1 . . . . . . . 1 . . .
    o  . . . . . 1 . . . 1 . . . . 1 1 . . . . . . . . . . . . . . 1 . . 5 . 1 . . . . . 1 . 4 . 1 . 1 .
    p  . . . 1 . 1 1 . . 1 2 . 1 . . . . 1 . . . . 1 2 . 1 1 . . 1 . 1 . . . 1 . 3 . . . 1 1 1 1 1 . . .
    q  . . . . . . . 2 . . . 1 . 1 2 . 1 . 1 . . . . . . . 1 2 . . . . . 1 . . . . . 1 . 1 2 . . . . 2 .
    r  . . . . . . . . 2 . 3 . 4 . . . . 1 3 . . . 1 1 2 . . . . 1 . . . . . . . . . . . . . . . 1 . 1 .
    s  . . . 1 . . . . 2 . 2 . . 1 . 1 . 1 2 . . . 3 1 . . 1 1 . 1 . . 1 . . 3 . 1 . 1 . 1 . 1 . 3 . 1 2
    t  . . . . . . . . 3 . . . 2 . 1 1 . . 2 . 1 . 3 . 1 . . . . 2 . . . . 2 1 . . . . 1 . . . . 1 . . .
    u  . . . 2 . 1 . 1 . 2 . . . 2 2 . 2 2 1 1 . . . . 1 . 1 1 . . . 2 . . . 1 . . 1 . . 1 . . 3 . . 3 .
    v  . 1 . . . 1 1 . . 1 . . . 1 . . 1 . . . 2 . . . 1 . 1 . . 1 . . 1 . 1 2 . . 1 . . . . 2 . . . . .
    w  . 2 . . . 3 . . . . . . . 2 . . 2 1 . 1 . . . . . 1 1 . . 1 6 3 . . . 1 . . 2 . . 2 . . 1 . 1 . 1
    x  . . . . . . 1 1 . . 2 . . . 1 . 1 . . . . . . 1 . . 1 . . 1 . 1 1 3 1 . . . . . . . 3 2 . 1 . . 1
    y  . . . . . . . . 1 . 1 1 . . 1 1 . . . . . . 1 . 1 1 . 1 . . . . 1 . 1 . . 1 1 . . . . . . . . 2 .
    z  . . . . . . . . 1 2 2 2 1 . . . . . . . 2 . 1 1 2 2 . . . 2 . 1 1 1 2 . . 1 . 1 1 1 . 1 . . . . .
    
    digram frequency: Pride and Prejudice (non-alphabetic characters removed) 
    536406 characters     (each datum is ratio*10000; eg. 'a' ratio 777/10000, 'aa' ratio 1/10000)
       777 169 251 416 1293 224 187 635 705  16  60 403 275 703 746 153  12 602 617 870 279 107 229  16 237  17
          a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z
    a     1  30  24  47   0  12  18   2  30   0  11  55  29 149   1  17   0  79  96 107  10  28   9   0  23   0
    b     5   0   .   0  78   .   .   0   8   3   .  19   0   .  12   .   .   6   3   2  21   0   .   .  12   .
    c    26   0   6   0  46   0   .  42  10   .   8   6   0   0  58   0   2   6   0  24   7   .   0   .  10   .
    d    47  19   5   8  55   8   5  26  55   2   1   7  14  17  29   4   0   8  24  42   6   3  15   .  12   .
    e    99  17  51 114  46  28  13  36  49   2   4  71  47 125  30  25   4 221  99  92   3  30  44  14  30   .
    f    23   2   3   2  23  12   1  14  21   0   0   4   6   1  44   2   0  17   6  25   7   0   4   .   4   .
    g    22   4   1   1  26   2   1  35  15   0   0  11   4   3  15   1   0  13   7  14   3   0   4   .   2   .
    h   130   3   2   2 278   2   1   9  89   1   0   2   6   1  53   2   0   4   7  27   6   0   6   .   3   .
    i    20   7  31  28  28  14  16   6   0   0   6  33  34 188  40   3   0  28  95  92   0  16   4   1   0  14
    j     6   .   .   .   4   .   .   .   0   .   .   .   .   .   3   .   .   .   .   .   3   .   .   .   .   .
    k     3   0   0   0  20   1   0   5  11   0   0   1   0   9   2   0   0   0   3   2   0   0   2   .   1   .
    l    32   4   3  32  68  14   1   4  62   0   5  59   4   3  28   2   0   1   7  13   6   2   5   .  47   .
    m    43   6   1   1  60   2   1   4  32   0   0   1   7   2  26  14   0  21  11   9  14   0   4   .  16   .
    n    33   6  35 107  81   9  91  15  28   2   7  11   8  16  74   3   2   2  39  96   5   6  12   1  14   0
    o    10  17   9  15   6  77   5  14  11   1   8  24  52 116  28  14   0  75  30  62 117  10  39   0   4   0
    p    19   0   0   0  32   0   0   2   8   0   .  17   0   0  19  13   .  25   4   7   3   0   1   .   2   .
    q     .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   0  12   .   .   .   .   .
    r    46  12  22  26 142  13   6  16  48   1   3  13  18  14  45   7   0  15  52  47   7   5  15   .  27   .
    s    54  15  15   7  78  11   5  66  56   1   2   8  13  11  50  20   1   5  53  90  30   3  19   .   4   .
    t    54  13   9   7  87   7   2 279  84   1   2  20  14   6 114   6   1  19  27  54  17   1  25   .  19   1
    u    12   5  21   6   8   1  16   2   8   0   1  33   7  27   1   9   0  49  33  36   0   0   3   0   0   0
    v     7   .   .   .  80   .   .   .  16   .   .   .   .   .   4   .   .   0   .   .   0   .   .   .   0   .
    w    53   1   1   1  34   1   0  46  49   0   0   2   2  10  20   0   0   2   3   3   0   0   2   .   0   .
    x     1   0   3   .   1   0   .   0   1   .   .   .   0   .   0   5   0   .   .   3   0   .   0   .   0   .
    y    20   8   9  11  11   7   3  11  14   1   1   5   9   4  51   5   0   5  21  22   2   1  15   .   2   .
    z    12   .   .   .   1   .   .   .   0   .   .   0   .   .   .   .   .   .   .   .   .   .   1   .   2   2
    

    black chamber 1860

    FOR NEXT TIME: make column width divisible by keylength
    
    KRWAOIBCZMBPKSMVMWFEJMNMFIVMXKOTZIDIZPSZOVDLQKYVPIJU
    CBREALOVDILGYNDHWEYUKNTMRQXDLPOUYNSTSAKSAKYVSCKUSTOG
    WZWIXYKCXQFEJASBIOXPOQNEDJOZQSSGCAREAAVQCAVMVOSOUWXL
    YWANOWPFDWBMXTAVOJESAVOACMSVPZKNUMCKYDWTQQYCGVNWKCUW
    BLSNYBYVYTWAGZSTLMXQXTZMWIBGAVCWPATWYSLYSNBQONVWPTOO
    FIBLYDSDSVMISADPOAJBSADWGZUMNOFBRMWAKBOZZIWKOBREKKRW
    YLKISLSNSADIDEEMXBWOFLKGDHWLSAMONMBGLYSPOQNEDJOZQUFQ
    FMBSABITSBJIBGWAFCCKBIHBOFZEJBKXZESZCBYCGVPQBMOPKBRA
    KTYVQBWMXAESHMMBODABSAKLKWKVKNKEOZDHSBRICBWMXQXPDISV
    FIWEPWBCWVDCBIWADPOMGVKTSSSQCSXOOVKAVAYQYKYNVISVSTST
    SIXDWTQQYCGVNWGAKNSZCTFIWMNAKBRMVICMXMCSAVDPOPSQXBSN
    YJIQDADQKVGRABOZQIGZQQYVSAKZSIFERWKLKWNIDEVBRMGOJSKB
    LELEOMXAFLDPOUFQFMBSABIAKIV
    

    black chamber 48 bce

    HKR LRGMH MBXXMA FODXXM DHKYSAMDH HCBVM. MQIHOMFMAHV EMEOMRALHFD HAMDP FRVVBPSHABV. What does the message say? Who sent it? When?
    Hint: the Latin alphabet of that time had no J,U,W,Y,Z, and V would today be treated as U. So here is how the Caesar 3-shift cipher would be implemented. ABCDEFGHIKLMNOPQRSTVX DEFGHIKLMNOPQRSTVXABC

    black chamber 900

    ghrjdtip gszjwc chahyc yzi zy kwfzdtisx ghrdhrp eji zy vhp ghrdhrp

    black chamber 1500

    fg Y egf'n rmfn ng rkynj mfgnxjk nkmqjc oggb, Y rmfn ng rkynj m nxkyccjk, mfe ya Y xmqj ng Y'cc ayfe mfgnxjk hpocylxjk fgyegfnrmfnngrkynjmfgnxjknkmqjcoggbyrmfnngrkynjm nxkyccjkmfeyayxmqjngyccayfemfgnxjkhpocylxjk fgyzegfznrmfznngrzkynjzmfgznxjzknkzmqjczoggzbyrzmfnzngrkzynjm znxkzyccjzkmfzeyayzxmqjzngyzccayzfemzfgnzxjkhzpocyzlxjk
      '  ,  Yy a  b  c  e
      f  g  h  j  k  l  m  
      n  o  p  q  r  x 
    
      2  2  10 2  1  6  3  
      8  9  1  8  8  1  8 
     12  2  1  2  4  5
    
    keyphrase substn cipher. what does the message say? who sent it? when?

    black chamber 1599: trivial homophonic cipher

    hjnrydjcidzdxhqtifhysskvlefxnochyldrevhewouldbesucceedjdby maryavdthjnyfnzcjssaryjlizqbjthbythystimjhzwasquitj dyzzyvzryanxiousavdqphysycqlwrzckixwasagreqtrjlijfwhenhjdyed

    black chamber 1918

    _ _    _ _ _    ._.    ...    . 
    _._.    _ _ _    _..    .    ...  
    _    ..    ._..    ._..    .._
    ...    .    _..    _    _ _ _ 
    _..    ._    _._ _    .._    _.. 
    ..._    .._.    _.._    .._.    _ _.
    _..    _ _.    ..._    _..    ._  
    ..._    .._.    _..    .._.    ._  
    _.._    _.._    ..._    _.._    ._  
    ..._    ..._    ._    ..._    _ _. 
    _..    .._.    ..._    _ _.    ..._  
    _..    ..._    _.._    _ _.    _ _.
    ..._    _..    _ _.    .._.    _..  
    ..._    _..    _..    
    _ _.    .._.    _.._  
    

    black chamber 1942

    u  n  i  v  e  r  s  i  t  a  t
    
    F  U  U  X  U  S  A  J  T  S  I  E  N  C  V  R  T  M  P  T  N  A  R
    

    black chamber: evolution of one-time-pad

    xli izspyxmsr sj xli sri-xmqi-teh
    
    Ycpgvcvcmc lkdpi pfi Rcnc-gjpkc em pfi 4pf aimpjkv co. 
    Ep emawjoig c oigaketpedm dh c gjxgpepjpedm aetfik.
    
    .d-mryli-mk6iy8odbva+%7iv7mbv#o7-yrimh#-h.ola%
    b18.1y7-8y7hik7'm6og7o1-9aymro1-by71-7k1hi'+a7iyl/-
    +bi98a96+ry-logo6j8rik7l1i6/ysb-kmymrsh1-khsshi
    k7'mloy6/-+ry-loyh-m6sh1ykhsshi+ai98b9r+l-y6oaiv1hhi
    
    dydmeiccyhmyutwmgqmwgpxphvfcewgowprvgcwtq
    jalprfcmivgenmrfgcwcpgpeugnjftmmprqlepogw
    yzvfjgykvfkdkwcudifmvsitqqmwgpxphvfcelqkq
    alqlkngknjpvuytpwwqeptvgdwivmnpxvctaekphc
    issgygayplpaqkd
    
    bdpoajhniyzqmurouuciknlztko
    
    data for 3rd cipher
    data for 4th cipher
    196 characters  27 different    (each datum is count)
       2   3  16   3   8   6   7   2  13   1   8  11   7  16
         2   7   3  10  12   5   7   2  15   8  10   8   4
       # % ' + - . / 1 6 7 8 9 a b d g h i j k l m o r s v y
    #  . . . . 1 . . . . . . . . . . . . . . . . . 1 . . . .
    %  . . . . . . . . . 1 . . . 1 . . . . . . . . . . . . .
    '  . . . 1 . . . . . . . . . . . . . . . . . 2 . . . . .
    +  . 1 . . . . . . . . . . 2 1 . . . . . . 1 . . 2 . . .
    -  . . . 2 . . . . . 1 1 1 . 1 . . 1 . . 2 2 3 . . . . 2
    .  . . . . . . . 1 . . . . . . 1 . . . . . . . 1 . . . .
    /  . . . . 2 . . . . . . . . . . . . . . . . . . . . . 1
    1  . . . . 4 . . . . . 1 . . . . . 2 1 . . . . . . . . 2
    6  . . . 1 . . 2 . . . . . . . . . . 1 1 . . . 2 . 1 . .
    7  . . 2 . 2 . . 1 . . . . . . . . 1 2 . 1 1 1 1 . . . .
    8  . . . . . 1 . . . . . . 1 1 . . . . . . . . 1 1 . . 1
    9  . . . . . . . . 1 . 2 . 1 . . . . . . . . . . 1 . . .
    a  . 1 . 1 . . . . . 1 . 1 . . . . . 2 . . . . . . . . 1
    b  . . . . 1 . . 1 . . . 1 . . . . . 1 . . . . . . . 2 1
    d  . . . . 1 . . . . . . . . 1 . . . . . . . . . . . . .
    g  . . . . . . . . . 1 . . . . . . . . . . . . 1 . . . .
    h  1 . . . 1 1 . 2 . . . . . . . . 1 5 . . . . . . 2 . .
    i  . . 1 1 1 . . . 1 . . 2 . . . . . . . 3 . 1 . . . 2 2
    j  . . . . . . . . . . 1 . . . . . . . . . . . . . . . .
    k  . . . . . . . 1 1 3 . . . . . . 2 . . . . 1 . . . . .
    l  . . . . 1 . 1 1 . . . . 1 . . . . 1 . . . . 3 . . . .
    m  . . . . . . . . 2 . . . . 1 . . 1 . . 1 1 . . 3 . . 1
    o  . . . . . . . 2 1 1 . . 1 . 1 2 . . . . 1 . . . . . 2
    r  . . . 1 . . . . . . . . . . . . . 2 . . . . 1 . 1 . 3
    s  . . . . . . . . . . . . . 1 . . 4 . . . . . . . 2 . .
    v  1 . . . . . . 1 . 1 . . 1 . . . . . . . . . . . . . .
    y  . . . . 2 . . . 2 3 1 . . . . . 1 . . 1 2 2 . 1 1 . .
    
    length 4 substring frequencies
     a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z 
     0  0  3  1  4  3  4  1  2  2  2  2  3  2  0  2  3  0  0  1  1  1  3  1  4  0 45 0.0385
     0  0  2  1  1  2  3  1  3  1  3  1  1  1  0  8  3  1  1  4  2  2  3  0  1  0 45 0.0524
     3  0  2  3  2  2  5  2  0  1  2  1  3  0  0  3  2  2  1  1  0  5  2  2  1  0 45 0.0405
     2  0  4  1  1  1  3  0  1  0  1  2  4  2  2  4  2  1  1  1  1  3  4  0  2  1 44 0.0372
    0.0422
    length 5 substring frequencies
     a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z 
     2  0  1  1  0  2  4  0  1  0  2  0  2  0  0  0  4  2  1  2  2  8  2  0  0  0 36 0.0741
     0  0  3  0  0  5  5  0  0  2  1  2  3  1  1  4  3  0  1  0  0  0  1  0  4  0 36 0.0664
     1  0  5  2  3  0  4  1  0  1  3  0  1  2  0  1  3  0  0  2  2  1  1  2  1  0 36 0.0463
     2  0  2  3  2  0  0  0  0  1  0  2  4  2  0 10  0  0  1  1  0  0  2  0  3  1 36 0.0973
     0  0  0  0  3  1  2  3  5  0  2  2  1  0  1  2  0  2  0  2  0  2  6  1  0  0 35 0.0621
    0.0693
    length 6 substring frequencies
     a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z 
     1  0  4  1  0  0  3  3  0  1  0  1  5  0  0  3  1  0  0  1  1  4  0  0  1  0 30 0.069
     1  0  3  0  0  2  1  0  1  0  2  1  1  1  2  3  0  1  1  2  1  3  3  0  1  0 30 0.0356
     2  0  0  2  0  3  5  0  2  2  1  0  0  2  0  1  2  1  0  0  0  2  4  0  1  0 30 0.0578
     1  0  2  2  1  1  4  1  1  0  1  0  2  0  0  5  2  1  1  2  1  0  1  0  1  0 30 0.0467
     0  0  1  1  6  2  1  0  0  0  3  2  1  0  0  1  2  1  1  1  0  0  1  3  3  0 30 0.0601
     0  0  1  0  1  0  1  0  2  1  1  2  2  2  0  4  3  0  0  1  1  2  3  0  1  1 29 0.0405
    0.0516
    gcw 21
    qmwgpxphvfce 90