Tuesday, November 1, 2011

Edgar Allen Poe Cipher


Edgar Allen Poe had a long fascination with cryptology. Ciphers played a large roll in The Gold Bug and many of his works referred to "secret writings." He also ran his own cryptography contest where he challenged his readers to send him ciphers and he would break them and publish the solution. He claimed to have solved all legitimate ciphers sent to him except two sent in by a Mr W. B. Tyler, a person who may have never existed but actually been a pen name for Poe.

These two ciphers sat unsolved for 150 years.

Cipher 1

Cipher 2
The first was broken in 1992 by Terence Whalen. Whalen used a clue from the correspondence between Tyler and Poe that mentioned the difficulty of solving a cipher that had the letters of words reversed and the spaces between words removed. He identified a repeating 3 letter pattern that turned out to be "the" (actually, "eht"). He was able to break this transposed mono-substitution cipher by hand.

The second was broken  in 2000 by Gil Broza by writing a program and then manually went through patterns to find plausible words. It is a homophonic cipher made somewhat harder by several typos added in the printing process.

"Now what," you might ask, "are the solutions to the ciphers?" I'm not telling. Sure, you could Google them, but I'm going to show you how to break them in a heartbeat using modern free and open source software.

Here is cipher 1 converted into ASCII (and fixed a bit):
,†§:‡][,?‡),[¡¶?,†,)¡,§[¶¦,:¶![
§(,†§¡¨(?…?,©©(……¡([,¶*.…[§¡¶§¡
¶]¿,†§[?(§[::(†[.…(*;(¨(,†§¡‡[*
:,]!¶†¨]?©!¶…†§¶¨,©(†¡(,?‡§(¡
<¡¶[?(,;§‡>‡]†§§:(†[†[¶?‡]:
*¡¶:(§?]!¶†§‡];§?‡†¡‡…¶!(,†§?(¨
*][§¡`¡,:,,†§<),?¨*]?,§§(!…¡(,
†§†[‡!)*][…:?]¨

Since most solvers are extremely picky about their input formats (usually in very non-obvious ways) here it is in capital letters.

TAKFQMOTHQSTOCNHTATSCTKONXTOTFNJOKGTAKCWGHEHTVVGEECGOTNITEOKNKCNMPTAKOHGKOFFGAOTEGIZGWGTAKCQOIFTOJNAWMHVJNEAKNWTVGECGTHQKGCYCNOCNOHGTZKQBQMAKFFGAOAONHQMFICNFGKHMJJNAKQMZKHQACQENJGTAKHGWIMOKCTJTFTTAKYSTHWIMHTKKGJECGTAKAOQHSIMOEFHMW

As we know the letters are reversed, lets reverse the entire string and fix it later. Here is a great text manipulator.

Now we just need a good cryptogram solver. There are many tools that will do this, but here is an excellent online cryptogram solver.

Plug it in, use patristocrat mode, and voila. You have to read the words from right to left, but not bad for a few seconds of work to solve something that remained unsolved for 150 years, eh?

Other tools you could use are cryptocrack, and zkdecrypto has build in reversing feature but is more of a homophonic cipher solver.

Next we want the cipher for the second cipher. Apparently Gil Broza tried to prevent people from getting enjoyment out of his work by releasing it in a locked PDF. This would be enough to stop a kid from using the cipher and discouraging him or her from the field, but all it takes is a text extractor to get around it. Here's the text:

[D[* ]L[i]k [O[G[X[E[W [P]f]h[F[y]y [$]B[U[H ]T[I[A [V[Q]S[M]G]&
[,[3[T[b[j[( [S[N[B [2[s]A[L]N[K]g[Y]Q ]J[C[P [)]V[%[l [H]@[Z[6[-]2]C
[@])]t]K]r[f ]^]R ]$]D]3]&[L ]=]W[O [h[j[5]X]I]!]F]R]i [g].[7]y]M[4]e [T[a
[Q[9]4[)[B[X[P[e[E [y[G]+[d[U]P ]B]V ]S]T[A]V]a ]u]0]Z [)[2]G[D[Y[R]C
[3[7[1 ]Y[F[K[,[3[6[f [Z]2[N[s[#[4])[@ ]R]k ]O]*]t [%[9]$]r [;]Q[h [M]j[6
[+]2[V]i[e[6[X[7[B ]A]m[L [$]!]-[A[5[!]([O [i[y[1]J[D[V [b]4]5[f[s[g]F]L]P]@
[S[^]Z[l [C[E]M[$[S[W [b[G[e[*])[h [a[N[j[m]. [s]e]A]y]h]T]a]= ]Y[a[k]t[X[D[I[,
]+]g ]J[C]P [9]E]r[K [o[F]Q[A]R]L [$]D[O[T[. ]k[2[r ]O]*]t ]3[9[)[B]G[P
[S[E[B ]3]N[1[L]Q[u [L[p[7 ]$]j[n[9]= [a[t]g]5 [d[8[![y ]W]V[% [c[E[p]i]m]X]a]y
[s].[J]Z [e[I[f [![M]k [,[.[K[S]S[6 [H])[i[t]A[W [&]B[P [q[T]@]2 [3]4[.[j [*]0[=
[U]&]r[2]^[m[e [n[k [V[F]H]V [l[D[a[h [X]M]K[T[I[0], [Y[e ]=]j]r [a]3[F]h[W
[X]Q]C]#[![U].]+]4]!]a ]g[s [1 [A]G[O[i]Y [u]m[e[y [r[^[2 [G]I]O[Q]B[g
]N[B]T[E[m[M[& [n[k [L[2[%]^]* [S]=[I[1]P]@]S[l [N]Z[& ]3[g[)[j]h ]y]3[-[6[f
[R[Z]-[K [C])]e ].[@ ]W]t[X [J[3[#]$]A]r[U]F[Q[, ]G[D[7]y]5[B[*]i
[b[;]N[L [L[1[)]P[h [5[W [e[4[T[%[Y[d]k ]T[I[A [V[8]R]&[M[F[)[=
[v]V]E]7]&]@[P ]3[7[1 [$[N[6]9 ]W]2 ]#])]e]U[j]Y[r]t[f ]J]D]V ]h[p[h]r
[![y[S[X[t]C]4]F]a ]g[s ]A]m[L [@[Q[I[g[m[,]0[* ]W]2 ]$]f[U[i[K]y ]^]M
[A]G[G[b [M]j[6 [0[R]N]+[a]D[Q [c[#[r ]i[*[; [,]r[7]O[E[l ]k[S].[W[t[1
[C[F]6 ]9]c [y]! [f[j[e[% ]I]D]B]@]S])[P ]i]*[; [V]-[k]A[3]& ]C]T[X[h
[q[d[J]W [&[2]J[^]P]e [l[n[d]5[A [K ]0]3[)]V ]1 [g]4[*]^[E]2 [-[t]a ]=]j[.[I
[K[9 [e[m[y [i]+ ]G]3]5

I wrote a brief python program to convert this into numerals, resulting in:

 55 19 109 37 51 71 81 2 9 34 27 115 78 25 5 32 64 79 47 107 57 13 12 33 45 73 44 26 40 20 36 46 75 30 133 15 82 24 17 31 23 4 70 14 58 95 83 69 80 27 6 10 39 52 107 54 110 8 104 21 67 94 18 53 120 11 29 74 72 63 68 3 40 4 43 48 71 16 30 106 121 108 91 98 72 50 49 41 22 32 99 105 77 46 28 45 42 38 6 24 2 27 1 9 5 81 65 76 47 56 79 10 73 57 12 10 35 135 92 85 6 17 26 55 95 113 67 36 22 7 84 25 14 20 36 8 29 110 21 82 31 103 105 18 94 72 51 100 89 53 39 42 63 11 93 83 16 44 59 8 130 21 33 50 1 8 2 22 24 23 96 4 64 91 102 12 106 62 128 71 37 5 7 69 55 33 75 38 66 29 31 49 98 109 56 54 15 101 85 52 80 9 99 64 15 34 75 81 1 19 18 16 28 82 30 60 41 31 77 23 32 78 57 35 43 84 28 86 53 2 55 13 20 65 58 69 80 56 42 125 11 14 134 25 83 12 72 109 64 68 71 46 90 51 17 87 100 89 53 3 42 6 24 26 27 15 9 24 3 70 7 4 83 117 4 111 22 63 59 97 42 43 28 61 58 66 76 119 62 5 48 10 39 122 9 111 50 96 121 35 32 31 41 112 85 1 13 29 62 44 51 20 90 14 15 73 8 107 18 37 61 23 34 88 79 27 123 46 54 21 36 38 90 30 19 92 114 47 40 11 17 74 60 1 97 86 33 25 137 10 52 55 28 16 2 99 120 46 13 116 131 95 1 43 59 11 28 3 25 78 34 2 83 67 118 62 47 41 65 38 91 35 58 31 7 12 26 71 37 84 117 96 1 5 87 101 17 81 108 100 45 79 49 70 24 57 9 60 44 88 97 86 4 17 39 74 89 15 43 13 7 56 54 73 52 82 85 88 3 49 6 30 78 32 3 104 8 29 113 110 102 14 80 18 77 41 94 48 53 2 112 36 103 63 23 11 47 98 45 20 26 55 22 32 66 24 19 50 75 93 70 4 4 7 6 56 16 106 34 1 105 46 39 95 76 51 57 13 12 33 119 72 40 44 25 6 114 136 10 125 129 40 54 27 3 22 7 64 82 8 124 48 21 118 18 77 138 30 84 87 53 29 69 68 10 78 111 16 11 62 5 15 2 61 67 38 98 35 58 31 23 96 4 94 45 13 49 60 20 92 19 48 21 63 115 47 37 14 32 74 99 12 26 81 75 44 59 8 116 113 70 65 28 68 45 122 103 87 50 19 93 20 11 22 100 9 52 51 15 41 34 61 7 80 25 127 124 126 5 91 29 30 1 39 108 68 79 54 73 18 27 50 89 93 33 102 86 23 36 40 67 57 2 16 123 76 112 48 88 17 69 101 56 77 52 97 76 66 12 14 92 3 6 10 132 49 38 19 74 9 21 104 61 35 43 59 90 13 14 42 1 60 5 37 65 26 3 66

Now we just need to plug it into our favorite homophonic substitution cipher solver. Cryptcrack is a great tool, but it can only handle 01-99 numbers, so it is out. Zkdecrytpto, however, can handle numbers 1-230 so it is perfect. Read in the cipher as numerals, initialize the key, and hit "Start." Because of all the typos it has trouble coming up with the solution and will go down many false roads, and the solution itself is somewhat subjective. But you can lock in letters for decryption and manually look for patterns. I suspect if I corrected the typos first the tool would do a much better job, and I will do that if requested. The fact that this tool has so much trouble makes the original solution all the more impressive.