#!/usr/bin/python # Play around with the Beale ciphers. # Adam Sampson """ Sources: http://www.und.edu/org/crypto/crypto/general.crypt.info/beale/more.beale/notes This is clearly working from the wrong DOI, but its suggestion of how B1 might have been encoded is interesting. Trouble is that B2 is so short, so it's unlikely to be that... "Another [B1] string emerges and the longest string is extended if a count of 5 is added to elements above 604." [but this breaks B2] http://rogergrambihler.tripod.com/BealeHoax.htm Best DOI discussion I've seen. http://www.ciphermysteries.com/2010/06/22/jim-gilloglys-beale-sequence-revisited Bad DOI. http://members.fortunecity.com/jpeschel/gillog3.htm The original paper reporting the run. But the analysis is (again) relying on a dodgy DOI -- "23 examples" of off-by-one errors in B2? Nope, nothing like that; three. http://www.myoutbox.net/blove.htm Makes the same point about the DOI. :) Things to note: Having corrected the DOI text against TBP, then tried book-decoding B1, the "147 436 195" run comes out as "abcdefghiijklmmnohpp". Most sources I've seen -- e.g. ciphermysteries -- think 195 should be "f" not "c", but it's definitely "changed" in the TBP DOI. RG gets it right. The "h" at the end is 301, which is "history" in the TBP DOI. I guess it should have been 302, "of"? (It would be easy to read "(300) history of" and think "of" was 301, looking for an o... but 301 is used correctly for h in B2. A typesetting error? Or did 301 end up in both the h and o lists?) Decoding B2 with corrected DOI leaves only a few errors compared to the (presumed) plaintext: 95 (3x): TBP says "inalienable" where other texts say "unalienable", but that word is used for "u" in B2. 84 (2x): "created" should be "e" (85 equal) -- miscount? "(80) all men are created equal" 53: "respect" should be "t" (54 to) -- same error "(50) a decent respect to" 96: "rights" should be "u" (95 un/inalienable) -- other direction These are all earlyish; strong bias towards lower numbers. """ import re B1 = [ 71, 194, 38, 1701, 89, 76, 11, 83, 1629, 48, 94, 63, 132, 16, 111, 95, 84, 341, 975, 14, 40, 64, 27, 81, 139, 213, 63, 90, 1120, 8, 15, 3, 126, 2018, 40, 74, 758, 485, 604, 230, 436, 664, 582, 150, 251, 284, 308, 231, 124, 211, 486, 225, 401, 370, 11, 101, 305, 139, 189, 17, 33, 88, 208, 193, 145, 1, 94, 73, 416, 918, 263, 28, 500, 538, 356, 117, 136, 219, 27, 176, 130, 10, 460, 25, 485, 18, 436, 65, 84, 200, 283, 118, 320, 138, 36, 416, 280, 15, 71, 224, 961, 44, 16, 401, 39, 88, 61, 304, 12, 21, 24, 283, 134, 92, 63, 246, 486, 682, 7, 219, 184, 360, 780, 18, 64, 463, 474, 131, 160, 79, 73, 440, 95, 18, 64, 581, 34, 69, 128, 367, 460, 17, 81, 12, 103, 820, 62, 116, 97, 103, 862, 70, 60, 1317, 471, 540, 208, 121, 890, 346, 36, 150, 59, 568, 614, 13, 120, 63, 219, 812, 2160, 1780, 99, 35, 18, 21, 136, 872, 15, 28, 170, 88, 4, 30, 44, 112, 18, 147, 436, 195, 320, 37, 122, 113, 6, 140, 8, 120, 305, 42, 58, 461, 44, 106, 301, 13, 408, 680, 93, 86, 116, 530, 82, 568, 9, 102, 38, 416, 89, 71, 216, 728, 965, 818, 2, 38, 121, 195, 14, 326, 148, 234, 18, 55, 131, 234, 361, 824, 5, 81, 623, 48, 961, 19, 26, 33, 10, 1101, 365, 92, 88, 181, 275, 346, 201, 206, 86, 36, 219, 324, 829, 840, 64, 326, 19, 48, 122, 85, 216, 284, 919, 861, 326, 985, 233, 64, 68, 232, 431, 960, 50, 29, 81, 216, 321, 603, 14, 612, 81, 360, 36, 51, 62, 194, 78, 60, 200, 314, 676, 112, 4, 28, 18, 61, 136, 247, 819, 921, 1060, 464, 895, 10, 6, 66, 119, 38, 41, 49, 602, 423, 962, 302, 294, 875, 78, 14, 23, 111, 109, 62, 31, 501, 823, 216, 280, 34, 24, 150, 1000, 162, 286, 19, 21, 17, 340, 19, 242, 31, 86, 234, 140, 607, 115, 33, 191, 67, 104, 86, 52, 88, 16, 80, 121, 67, 95, 122, 216, 548, 96, 11, 201, 77, 364, 218, 65, 667, 890, 236, 154, 211, 10, 98, 34, 119, 56, 216, 119, 71, 218, 1164, 1496, 1817, 51, 39, 210, 36, 3, 19, 540, 232, 22, 141, 617, 84, 290, 80, 46, 207, 411, 150, 29, 38, 46, 172, 85, 194, 39, 261, 543, 897, 624, 18, 212, 416, 127, 931, 19, 4, 63, 96, 12, 101, 418, 16, 140, 230, 460, 538, 19, 27, 88, 612, 1431, 90, 716, 275, 74, 83, 11, 426, 89, 72, 84, 1300, 1706, 814, 221, 132, 40, 102, 34, 868, 975, 1101, 84, 16, 79, 23, 16, 81, 122, 324, 403, 912, 227, 936, 447, 55, 86, 34, 43, 212, 107, 96, 314, 264, 1065, 323, 428, 601, 203, 124, 95, 216, 814, 2906, 654, 820, 2, 301, 112, 176, 213, 71, 87, 96, 202, 35, 10, 2, 41, 17, 84, 221, 736, 820, 214, 11, 60, 760, ] B2 = [ 115, 73, 24, 807, 37, 52, 49, 17, 31, 62, 647, 22, 7, 15, 140, 47, 29, 107, 79, 84, 56, 239, 10, 26, 811, 5, 196, 308, 85, 52, 160, 136, 59, 211, 36, 9, 46, 316, 554, 122, 106, 95, 53, 58, 2, 42, 7, 35, 122, 53, 31, 82, 77, 250, 196, 56, 96, 118, 71, 140, 287, 28, 353, 37, 1005, 65, 147, 807, 24, 3, 8, 12, 47, 43, 59, 807, 45, 316, 101, 41, 78, 154, 1005, 122, 138, 191, 16, 77, 49, 102, 57, 72, 34, 73, 85, 35, 371, 59, 196, 81, 92, 191, 106, 273, 60, 394, 620, 270, 220, 106, 388, 287, 63, 3, 6, 191, 122, 43, 234, 400, 106, 290, 314, 47, 48, 81, 96, 26, 115, 92, 158, 191, 110, 77, 85, 197, 46, 10, 113, 140, 353, 48, 120, 106, 2, 607, 61, 420, 811, 29, 125, 14, 20, 37, 105, 28, 248, 16, 159, 7, 35, 19, 301, 125, 110, 486, 287, 98, 117, 511, 62, 51, 220, 37, 113, 140, 807, 138, 540, 8, 44, 287, 388, 117, 18, 79, 344, 34, 20, 59, 511, 548, 107, 603, 220, 7, 66, 154, 41, 20, 50, 6, 575, 122, 154, 248, 110, 61, 52, 33, 30, 5, 38, 8, 14, 84, 57, 540, 217, 115, 71, 29, 84, 63, 43, 131, 29, 138, 47, 73, 239, 540, 52, 53, 79, 118, 51, 44, 63, 196, 12, 239, 112, 3, 49, 79, 353, 105, 56, 371, 557, 211, 505, 125, 360, 133, 143, 101, 15, 284, 540, 252, 14, 205, 140, 344, 26, 811, 138, 115, 48, 73, 34, 205, 316, 607, 63, 220, 7, 52, 150, 44, 52, 16, 40, 37, 158, 807, 37, 121, 12, 95, 10, 15, 35, 12, 131, 62, 115, 102, 807, 49, 53, 135, 138, 30, 31, 62, 67, 41, 85, 63, 10, 106, 807, 138, 8, 113, 20, 32, 33, 37, 353, 287, 140, 47, 85, 50, 37, 49, 47, 64, 6, 7, 71, 33, 4, 43, 47, 63, 1, 27, 600, 208, 230, 15, 191, 246, 85, 94, 511, 2, 270, 20, 39, 7, 33, 44, 22, 40, 7, 10, 3, 811, 106, 44, 486, 230, 353, 211, 200, 31, 10, 38, 140, 297, 61, 603, 320, 302, 666, 287, 2, 44, 33, 32, 511, 548, 10, 6, 250, 557, 246, 53, 37, 52, 83, 47, 320, 38, 33, 807, 7, 44, 30, 31, 250, 10, 15, 35, 106, 160, 113, 31, 102, 406, 230, 540, 320, 29, 66, 33, 101, 807, 138, 301, 316, 353, 320, 220, 37, 52, 28, 540, 320, 33, 8, 48, 107, 50, 811, 7, 2, 113, 73, 16, 125, 11, 110, 67, 102, 807, 33, 59, 81, 158, 38, 43, 581, 138, 19, 85, 400, 38, 43, 77, 14, 27, 8, 47, 138, 63, 140, 44, 35, 22, 177, 106, 250, 314, 217, 2, 10, 7, 1005, 4, 20, 25, 44, 48, 7, 26, 46, 110, 230, 807, 191, 34, 112, 147, 44, 110, 121, 125, 96, 41, 51, 50, 140, 56, 47, 152, 540, 63, 807, 28, 42, 250, 138, 582, 98, 643, 32, 107, 140, 112, 26, 85, 138, 540, 53, 20, 125, 371, 38, 36, 10, 52, 118, 136, 102, 420, 150, 112, 71, 14, 20, 7, 24, 18, 12, 807, 37, 67, 110, 62, 33, 21, 95, 220, 511, 102, 811, 30, 83, 84, 305, 620, 15, 2, # vv 10, 8 is 108 in TBP 10, 8, 220, 106, 353, 105, 106, 60, 275, 72, 8, 50, 205, 185, 112, 125, 540, 65, 106, 807, 138, 96, 110, 16, 73, 33, 807, 150, 409, 400, 50, 154, 285, 96, 106, 316, 270, 205, 101, 811, 400, 8, 44, 37, 52, 40, 241, 34, 205, 38, 16, 46, 47, 85, 24, 44, 15, 64, 73, 138, 807, 85, 78, 110, 33, 420, 505, 53, 37, 38, 22, 31, 10, 110, 106, 101, 140, 15, 38, 3, 5, 44, 7, 98, 287, 135, 150, 96, 33, 84, 125, 807, 191, 96, 511, 118, 40, 370, 643, 466, 106, 41, 107, 603, 220, 275, 30, 150, 105, 49, 53, 287, 250, 208, 134, 7, 53, 12, 47, 85, 63, 138, 110, 21, 112, 140, 485, 486, 505, 14, 73, 84, 575, 1005, 150, 200, 16, 42, 5, 4, 25, 42, 8, 16, 811, 125, 160, 32, 205, 603, 807, 81, 96, 405, 41, 600, 136, 14, 20, 28, 26, 353, 302, 246, 8, 131, 160, 140, 84, 440, 42, 16, 811, 40, 67, 101, 102, 194, 138, 205, 51, 63, 241, 540, 122, 8, 10, 63, 140, 47, 48, 140, 288, ] B2_plaintext = re.sub(r'[^a-z]', '', """ i have deposited in the county of bedford about four miles from bufords in an excavation or vault six feet below the surface of the ground the following articles belonging jointly to the parties whose names are given in number three herewith the first deposit consisted of ten hundred and fourteen pounds of gold and thirty eight hundred and twelve pounds of silver deposited nov eighteen nineteen the second was made dec eighteen twenty one and consisted of nineteen hundred and seven pounds of gold and twelve hundred and eighty eight of silver also jewels obtained in st louis in exchange to save transportation and valued at thirteen thousand dollars the above is securely packed in iron pots with iron covers the vault is roughly lined with stone and the vessels rest on solid stone and are covered with others paper number one describes the exact locality of the vault so that no difficulty will be had in finding it """) B3 = [ 317, 8, 92, 73, 112, 89, 67, 318, 28, 96, 107, 41, 631, 78, 146, 397, 118, 98, 114, 246, 348, 116, 74, 88, 12, 65, 32, 14, 81, 19, 76, 121, 216, 85, 33, 66, 15, 108, 68, 77, 43, 24, 122, 96, 117, 36, 211, 301, 15, 44, 11, 46, 89, 18, 136, 68, 317, 28, 90, 82, 304, 71, 43, 221, 198, 176, 310, 319, 81, 99, 264, 380, 56, 37, 319, 2, 44, 53, 28, 44, 75, 98, 102, 37, 85, 107, 117, 64, 88, 136, 48, 151, 99, 175, 89, 315, 326, 78, 96, 214, 218, 311, 43, 89, 51, 90, 75, 128, 96, 33, 28, 103, 84, 65, 26, 41, 246, 84, 270, 98, 116, 32, 59, 74, 66, 69, 240, 15, 8, 121, 20, 77, 89, 31, 11, 106, 81, 191, 224, 328, 18, 75, 52, 82, 117, 201, 39, 23, 217, 27, 21, 84, 35, 54, 109, 128, 49, 77, 88, 1, 81, 217, 64, 55, 83, 116, 251, 269, 311, 96, 54, 32, 120, 18, 132, 102, 219, 211, 84, 150, 219, 275, 312, 64, 10, 106, 87, 75, 47, 21, 29, 37, 81, 44, 18, 126, 115, 132, 160, 181, 203, 76, 81, 299, 314, 337, 351, 96, 11, 28, 97, 318, 238, 106, 24, 93, 3, 19, 17, 26, 60, 73, 88, 14, 126, 138, 234, 286, 297, 321, 365, 264, 19, 22, 84, 56, 107, 98, 123, 111, 214, 136, 7, 33, 45, 40, 13, 28, 46, 42, 107, 196, 227, 344, 198, 203, 247, 116, 19, 8, 212, 230, 31, 6, 328, 65, 48, 52, 59, 41, 122, 33, 117, 11, 18, 25, 71, 36, 45, 83, 76, 89, 92, 31, 65, 70, 83, 96, 27, 33, 44, 50, 61, 24, 112, 136, 149, 176, 180, 194, 143, 171, 205, 296, 87, 12, 44, 51, 89, 98, 34, 41, 208, 173, 66, 9, 35, 16, 95, 8, 113, 175, 90, 56, 203, 19, 177, 183, 206, 157, 200, 218, 260, 291, 305, 618, 951, 320, 18, 124, 78, 65, 19, 32, 124, 48, 53, 57, 84, 96, 207, 244, 66, 82, 119, 71, 11, 86, 77, 213, 54, 82, 316, 245, 303, 86, 97, 106, 212, 18, 37, 15, 81, 89, 16, 7, 81, 39, 96, 14, 43, 216, 118, 29, 55, 109, 136, 172, 213, 64, 8, 227, 304, 611, 221, 364, 819, 375, 128, 296, 1, 18, 53, 76, 10, 15, 23, 19, 71, 84, 120, 134, 66, 73, 89, 96, 230, 48, 77, 26, 101, 127, 936, 218, 439, 178, 171, 61, 226, 313, 215, 102, 18, 167, 262, 114, 218, 66, 59, 48, 27, 19, 13, 82, 48, 162, 119, 34, 127, 139, 34, 128, 129, 74, 63, 120, 11, 54, 61, 73, 92, 180, 66, 75, 101, 124, 265, 89, 96, 126, 274, 896, 917, 434, 461, 235, 890, 312, 413, 328, 381, 96, 105, 217, 66, 118, 22, 77, 64, 42, 12, 7, 55, 24, 83, 67, 97, 109, 121, 135, 181, 203, 219, 228, 256, 21, 34, 77, 319, 374, 382, 675, 684, 717, 864, 203, 4, 18, 92, 16, 63, 82, 22, 46, 55, 69, 74, 112, 134, 186, 175, 119, 213, 416, 312, 343, 264, 119, 186, 218, 343, 417, 845, 951, 124, 209, 49, 617, 856, 924, 936, 72, 19, 28, 11, 35, 42, 40, 66, 85, 94, 112, 65, 82, 115, 119, 236, 244, 186, 172, 112, 85, 6, 56, 38, 44, 85, 72, 32, 47, 63, 96, 124, 217, 314, 319, 221, 644, 817, 821, 934, 922, 416, 975, 10, 22, 18, 46, 137, 181, 101, 39, 86, 103, 116, 138, 164, 212, 218, 296, 815, 380, 412, 460, 495, 675, 820, 952, ] # The problem with a lot of coverage of this on the web is that they don't say # exactly which version of the DOI they're using. They differ quite a bit! # # This is intended to match the numbering on the DOI in the original # publication (TBP): # http://www.archive.org/stream/TheBealePapers#page/n15/mode/2up # # I started with the WikiSource text (WS): # http://en.wikisource.org/wiki/United_States_Declaration_of_Independence # # which is not quite right going by the picture (D): # http://upload.wikimedia.org/wikipedia/commons/6/68/Yale_Dunlap_Broadside.jpg # "to alter or *to* abolish" # "and *the* amount and payment" # # Distinguishing features of the text used in TBP: # "*inalienable* rights" (unalienable) -- error? # "encourage their *migration* hither" (migrations) # "altering, fundamentally, the *powers*" (forms) # "institute *a* new government" () # "mankind are *now* disposed" (more) -- error? # # Errors spotted by Roger G marked RG DOI = [ 'when', 'in', 'the', 'course', 'of', 'human', 'events', 'it', 'becomes', 'necessary', 'for', 'one', 'people', 'to', 'dissolve', 'the', 'political', 'bands', 'which', 'have', 'connected', 'them', 'with', 'another', 'and', 'to', 'assume', 'among', 'the', 'powers', 'of', 'the', 'earth', 'the', 'separate', 'and', 'equal', 'station', 'to', 'which', 'the', 'laws', 'of', 'nature', 'and', 'of', 'nature\'s', 'god', 'entitle', 'them', 'a', 'decent', 'respect', 'to', 'the', 'opinions', 'of', 'mankind', 'requires', 'that', 'they', 'should', 'declare', 'the', 'causes', 'which', 'impel', 'them', 'to', 'the', 'separation', 'we', 'hold', 'these', 'truths', 'to', 'be', 'self', 'evident', 'that', 'all', 'men', 'are', 'created', 'equal', 'that', 'they', 'are', 'endowed', 'by', 'their', 'creator', 'with', 'certain', # vv TBP says "inalienable", WS says "unalienable" # but it's used for "u"! 'u=inalienable', 'rights', 'that', 'among', 'these', 'are', 'life', 'liberty', 'and', 'the', 'pursuit', 'of', 'happiness', 'that', 'to', # vv 'these' WS RG 'secure', 'their', 'rights', 'governments', 'are', 'instituted', 'among', 'men', 'deriving', 'their', 'just', 'powers', 'from', 'the', 'consent', # vv 'whenever' WS RG 'of', 'the', 'governed', 'that', 'when', 'any', 'form', 'of', 'government', 'becomes', 'destructive', 'of', 'these', 'ends', 'it', 'is', 'the', 'right', 'of', 'the', # vv inserted - in D, not WS 'people', 'to', 'alter', 'or', 'to', 'abolish', # vv this "a" not in D/WS RG 'it', 'and', 'to', 'institute', 'a', 'new', 'government', 'laying', 'its', 'foundation', 'on', 'such', 'principles', 'and', 'organizing', 'its', 'powers', 'in', 'such', 'form', 'as', 'to', 'them', 'shall', 'seem', 'most', 'likely', 'to', 'effect', 'their', 'safety', 'and', 'happiness', 'prudence', 'indeed', 'will', 'dictate', 'that', 'governments', 'long', 'established', 'should', 'not', 'be', 'changed', 'for', 'light', 'and', 'transient', 'causes', 'and', 'accordingly', 'all', 'experience', 'hath', # vv 'more' WS RG 'shewn', 'that', 'mankind', 'are', 'now', 'disposed', 'to', 'suffer', 'while', 'evils', 'are', 'sufferable', 'than', 'to', 'right', 'themselves', 'by', 'abolishing', 'the', 'forms', 'to', 'which', 'they', 'are', 'accustomed', 'but', 'when', 'a', 'long', 'train', # | lb in D 'of', 'abuses', 'and', 'usurpations', 'pursuing', # 244 merged - miscount in TBP 'invariably', 'the', 'same', 'object+evinces', 'a', 'design', 'to', 'reduce', 'them', 'under', 'absolute', 'despotism', 'it', 'is', 'their', 'right', 'it', 'is', 'their', 'duty', 'to', 'throw', 'off', 'such', 'government', 'and', 'to', 'provide', 'new', 'guards', 'for', 'their', 'future', 'security', 'such', 'has', 'been', 'the', 'patient', 'sufferance', 'of', 'these', 'colonies', 'and', 'such', 'is', 'now', 'the', 'necessity', 'which', 'constrains', 'them', 'to', 'alter', 'their', 'former', 'systems', 'of', 'government', 'the', 'history', 'of', 'the', 'present', 'king', 'of', 'great', 'britain', 'is', 'a', 'history', 'of', 'repeated', 'injuries', 'and', 'usurpations', 'all', 'having', 'in', 'direct', 'object', 'the', 'establishment', 'of', 'an', 'absolute', 'tyranny', 'over', 'these', 'states', 'to', 'prove', 'this', 'let', 'facts', 'be', 'submitted', 'to', 'a', 'candid', 'world', 'he', 'has', 'refused', 'his', 'assent', 'to', 'laws', 'the', 'most', 'wholesome', 'and', 'necessary', 'for', 'the', 'public', 'good', 'he', 'has', 'forbidden', 'his', 'governors', 'to', 'pass', 'laws', 'of', 'immediate', 'and', 'pressing', 'importance', 'unless', 'suspended', 'in', 'their', 'operation', 'till', 'his', 'assent', 'should', 'be', 'obtained', 'and', 'when', 'so', 'suspended', 'he', 'has', 'utterly', 'neglected', 'to', 'attend', 'to', 'them', 'he', 'has', 'refused', 'to', 'pass', 'other', 'laws', 'for', 'the', 'accommodation', 'of', 'large', 'districts', 'of', 'people', 'unless', # vv 'the' WS RG 'those', 'people', 'would', 'relinquish', 'their', 'right', 'of', 'representation', 'in', 'the', 'legislature', 'a', 'right', 'inestimable', 'to', 'them', 'and', 'formidable', 'to', 'tyrants', 'only', 'he', 'has', 'called', 'together', 'legislative', 'bodies', 'at', 'places', 'unusual', 'uncomfortable', 'and', 'distant', 'from', 'the', 'depository', 'of', 'their', 'public', 'records', 'for', 'the', 'sole', 'purpose', 'of', 'fatiguing', 'them', 'into', 'compliance', 'with', 'his', 'measures', 'he', 'has', 'dissolved', 'representative', 'houses', 'repeatedly', 'for', 'opposing', 'with', 'manly', 'firmness', 'his', 'invasions', 'on', 'the', 'rights', 'of', 'the', 'people', # 480 remove duplicate (two 480s in TBP) # 'he', 'has', 'refused', 'for', # 'a', 'long', 'time', 'after', 'such', # 'dissolutions', 'to', 'cause', 'others', 'to', 'be', 'elected', 'whereby', 'the', 'legislative', 'powers', 'incapable', 'of', 'annihilation', 'have', 'returned', 'to', 'the', 'people', 'at', 'large', 'for', 'their', 'exercise', 'the', 'state', 'remaining', 'in', 'the', 'mean', 'time', 'exposed', 'to', 'all', 'the', # vv 'dangers' WS RG 'danger', 'of', 'invasion', 'from', 'without', 'and', 'convulsions', 'within', 'he', 'has', 'endeavoured', 'to', 'prevent', 'the', 'population', 'of', 'these', 'states', 'for', 'that', # vv 'for' WS RG 'purpose', 'obstructing', 'the', 'laws', 'of', 'naturalization', 'of', 'foreigners', 'refusing', 'to', 'pass', 'others', 'to', 'encourage', 'their', # vv 'migrations' in WS/D 'migration', 'hither', 'and', 'raising', 'the', 'conditions', 'of', 'new', 'appropriations', 'of', 'lands', 'he', 'has', 'obstructed', 'the', 'administration', 'of', 'justice', 'by', 'refusing', 'his', 'assent', 'to', 'laws', 'for', 'establishing', 'judiciary', 'powers', 'he', 'has', 'made', 'judges', 'dependent', 'on', 'his', 'will', 'alone', 'for', 'the', 'tenure', # vv inserted - in D not WS 'of', 'their', 'offices', 'and', 'the', 'amount', 'and', 'payment', 'of', 'their', 'salaries', 'he', 'has', 'erected', 'a', 'multitude', 'of', 'new', 'offices', 'and', 'sent', 'hither', 'swarms', 'of', 'officers', 'to', 'harass', 'our', 'people', 'and', 'eat', 'out', 'their', 'substance', 'he', 'has', # 627 merge 'among'/'us' (corrects 630-640 miscount) 'kept', 'among+us', 'in', 'times', 'of', 'peace', 'standing', 'armies', 'without', # vv RG says not -s? 'the', 'consent', 'of', 'our', 'legislature', # vv 'affected' WS RG 'he', 'has', 'offered', 'to', 'render', 'the', 'military', 'independent', 'of', 'and', 'superior', 'to', 'the', 'civil', 'power', 'he', 'has', 'combined', 'with', 'others', 'to', 'subject', 'us', 'to', 'a', 'jurisdiction', 'foreign', 'to', 'our', 'constitution', 'and', 'unacknowledged', 'by', 'our', 'laws', 'giving', 'his', 'assent', 'to', 'their', # vv 680 merge (corrects 670-680 miscount) 'acts+of', 'pretended', 'legislation', 'for', 'quartering', 'large', 'bodies', 'of', 'armed', 'troops', 'among', 'us', 'for', 'protecting', 'them', 'by', 'a', 'mock', 'trial', 'from', 'punishment', 'for', 'any', 'murders', 'which', 'they', 'should', 'commit', 'on', 'the', 'inhabitants', 'of', 'these', 'states', 'for', 'cutting', 'off', 'our', 'trade', 'with', 'all', 'parts', 'of', 'the', 'world', 'for', 'imposing', 'taxes', 'on', 'us', 'without', 'our', 'consent', 'for', 'depriving', 'us', 'in', 'many', 'cases', 'of', 'the', 'benefits', 'of', 'trial', 'by', 'jury', 'for', 'transporting', 'us', 'beyond', 'seas', 'to', 'be', 'tried', 'for', 'pretended', 'offences', 'for', 'abolishing', 'the', 'free', 'system', 'of', 'english', 'laws', 'in', 'a', 'neighbouring', 'province', 'establishing', 'therein', 'an', 'arbitrary', 'government', 'and', 'enlarging', 'its', 'boundaries', 'so', 'as', 'to', 'render', 'it', 'at', 'once', 'an', 'example', 'and', 'fit', 'instrument', 'for', 'introducing', 'the', 'same', # vv RG says not 'into' 'absolute', 'rule', 'in', 'these', 'colonies', 'for', 'taking', 'away', 'our', 'charters', 'abolishing', 'our', 'most', 'valuable', 'laws', # vv 'forms' in WS/D RG # vv 811 used for "y" 'and', 'altering', 'y=fundamentally', 'the', 'powers', 'of', 'our', 'governments', # 'governments' is end of numbering (816) in TBP; # I've not checked below here 'for', 'suspending', 'our', 'own', 'legislatures', 'and', 'declaring', 'themselves', 'invested', 'with', 'powers', 'to', 'legislate', 'for', 'us', 'in', 'all', 'cases', 'whatsoever', 'he', 'has', 'abdicated', 'government', 'here', 'by', 'declaring', 'us', 'out', 'of', 'his', 'protection', 'and', 'waging', 'war', 'against', 'us', 'he', 'has', 'plundered', 'our', 'seas', 'ravaged', 'our', 'coasts', 'burnt', 'our', 'towns', 'and', 'destroyed', 'the', 'lives', 'of', 'our', 'people', 'he', 'is', 'at', 'this', 'time', 'transporting', 'large', 'armies', 'of', 'foreign', 'mercenaries', 'to', 'compleat', 'the', 'works', 'of', 'death', 'desolation', 'and', 'tyranny', 'already', 'begun', 'with', 'circumstances', 'of', 'cruelty', 'and', 'perfidy', 'scarcely', 'paralleled', 'in', 'the', 'most', 'barbarous', 'ages', 'and', 'totally', 'unworthy', 'the', 'head', 'of', 'a', 'civilized', 'nation', 'he', 'has', 'constrained', 'our', 'fellow', 'citizens', 'taken', 'captive', 'on', 'the', 'high', 'seas', 'to', 'bear', 'arms', 'against', 'their', 'country', 'to', 'become', 'the', 'executioners', 'of', 'their', 'friends', 'and', 'brethren', 'or', 'to', 'fall', 'themselves', 'by', 'their', 'hands', 'he', 'has', 'excited', 'domestic', 'insurrections', 'among', 'us', 'and', 'has', 'endeavoured', 'to', 'bring', 'on', 'the', 'inhabitants', 'of', 'our', 'frontiers', 'the', 'merciless', 'indian', 'savages', 'whose', 'known', 'rule', 'of', 'warfare', 'is', 'an', 'undistinguished', 'destruction', 'of', 'all', 'ages', 'sexes', 'and', 'conditions', 'in', 'every', 'stage', 'of', 'these', 'oppressions', 'we', 'have', 'petitioned', 'for', 'redress', 'in', 'the', 'most', 'humble', 'terms', 'our', 'repeated', # vv 1005 used for "x" -- probably meant "sexes" above? 'petitions', 'x=have', 'been', 'answered', 'only', 'by', 'repeated', 'injury', 'a', 'prince', 'whose', 'character', 'is', 'thus', 'marked', 'by', 'every', 'act', 'which', 'may', 'define', 'a', 'tyrant', 'is', 'unfit', 'to', 'be', 'the', 'ruler', 'of', 'a', 'free', 'people', 'nor', 'have', 'we', 'been', 'wanting', 'in', 'attentions', 'to', 'our', 'british', 'brethren', 'we', 'have', 'warned', 'them', 'from', 'time', 'to', 'time', 'of', 'attempts', 'by', 'their', 'legislature', 'to', 'extend', 'an', 'unwarrantable', 'jurisdiction', 'over', 'us', 'we', 'have', 'reminded', 'them', 'of', 'the', 'circumstances', 'of', 'our', 'emigration', 'and', 'settlement', 'here', 'we', 'have', 'appealed', 'to', 'their', 'native', 'justice', 'and', 'magnanimity', 'and', 'we', 'have', 'conjured', 'them', 'by', 'the', 'ties', 'of', 'our', 'common', 'kindred', 'to', 'disavow', 'these', 'usurpations', 'which', 'would', 'inevitably', 'interrupt', 'our', 'connections', 'and', 'correspondence', 'they', 'too', 'have', 'been', 'deaf', 'to', 'the', 'voice', 'of', 'justice', # vv WS has 'and of' here RG 'and', 'consanguinity', 'we', 'must', 'therefore', 'acquiesce', 'in', 'the', 'necessity', 'which', 'denounces', 'our', 'separation', 'and', 'hold', 'them', 'as', 'we', 'hold', 'the', 'rest', 'of', 'mankind', 'enemies', 'in', 'war', 'in', 'peace', 'friends', 'we', 'therefore', 'the', 'representatives', 'of', 'the', 'united', 'states', 'of', 'america', 'in', 'general', 'congress', 'assembled', 'appealing', 'to', 'the', 'supreme', 'judge', 'of', 'the', 'world', 'for', 'the', 'rectitude', 'of', 'our', 'intentions', 'do', 'in', # vv RG says not 'by authority' 'the', 'name', 'and', 'by', 'the', 'authority', 'of', 'the', 'good', 'people', 'of', 'these', 'colonies', 'solemnly', 'publish', 'and', 'declare', 'that', 'these', 'united', 'colonies', 'are', 'and', 'of', 'right', 'ought', 'to', 'be', 'free', 'and', 'independent', 'states', 'that', 'they', 'are', 'absolved', 'from', 'all', 'allegiance', 'to', 'the', 'british', 'crown', 'and', 'that', 'all', 'political', 'connection', 'between', 'them', 'and', 'the', 'state', 'of', 'great', 'britain', 'is', 'and', 'ought', 'to', 'be', 'totally', 'dissolved', 'and', 'that', 'as', 'free', 'and', 'independent', 'states', 'they', 'have', 'full', 'power', 'to', 'levy', 'war', 'conclude', 'peace', 'contract', 'alliances', 'establish', 'commerce', 'and', 'to', 'do', 'all', 'other', 'acts', 'and', 'things', 'which', 'independent', 'states', 'may', 'of', 'right', 'do', 'and', 'for', 'the', 'support', 'of', 'this', 'declaration', 'with', 'a', 'firm', 'reliance', 'on', 'the', 'protection', 'of', 'the', 'divine', 'providence', 'we', 'mutually', 'pledge', 'to', 'each', 'other', 'our', 'lives', 'our', 'fortunes', 'and', 'our', 'sacred', 'honor', ] def get_book(c, bt): if c - 1 >= len(bt): return "*" else: return bt[c - 1][0] def decode_book(ct, bt): return "".join(get_book(c, bt) for c in ct) def diff(a, b, ct, bt): assert len(a) == len(b) for i in range(len(a)): if a[i] == b[i]: continue print ("%d:%s: expect '%s' but had '%s' from '%s' (%d)" % (i + 1, a[i-4:i+5], b[i], a[i], bt[ct[i] - 1], ct[i])) if __name__ == "__main__": print decode_book(B1, DOI) print B2_decoded = decode_book(B2, DOI) print B2_decoded print used = {} used_for = {} for c in B2: plain = get_book(c, DOI) used[c] = plain l = used_for.setdefault(plain, []) if c not in l: l.append(c) for char in sorted(used_for.keys()): print "%s: %3d: %s" % (char, len(used_for[char]), " ".join(["%d" % c for c in used_for[char]])) print width = 50 for start in range(1, len(DOI) + 1, width): s = "" for c in range(start, start + width): s += used.get(c, " ") print "%4d: %s" % (start, s) print diff(B2_decoded, B2_plaintext, B2, DOI)