{"id":19,"date":"2007-10-09T23:51:11","date_gmt":"2007-10-09T23:51:11","guid":{"rendered":"http:\/\/www.kith.org\/peter\/2007\/10\/09\/matrix_encryption\/"},"modified":"2018-01-05T03:03:01","modified_gmt":"2018-01-05T03:03:01","slug":"matrix_encryption","status":"publish","type":"post","link":"https:\/\/www.kith.org\/peter\/2007\/10\/09\/matrix_encryption\/","title":{"rendered":"Matrix encryption"},"content":{"rendered":"<p>Sorry for the long silence&#8211;was busy, then had to spend a bunch of time fixing some problems with the blog.  All fixed now, I think.<\/p>\n<p>Welcome, Dobe!  Thanks for posting!<\/p>\n<p>On my way home from work this evening, I suddenly remembered something I hadn&#8217;t thought of in years: at one point when I was a kid (no idea how old), Peter taught me a nifty encryption technique based on matrix multiplication.<\/p>\n<p>It turns out that this was a basic form of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Hill_cipher\">Hill cipher<\/a>, but I didn&#8217;t know that at the time.<\/p>\n<p>To use the system, we first had to create two tables for doing math on letters: a multiplication table and a division table.  Each letter corresponded to a number: A was 1, B was 2, etc.  I think space was zero.  It&#8217;s possible that we added a couple other characters to create a prime number of characters, but for simplicity in this description, let&#8217;s say we didn&#8217;t.  In that case, the multiplication and division were done <a href=\"http:\/\/en.wikipedia.org\/wiki\/Modular_arithmetic\">modulo<\/a> 27.  So A x A = 1 x 1 = 1 = A; B x C = 2 x 3 = 6 = F; M x Q = 13 x 17 = 221 = 5 mod 27 = E.  And so on.  Division was presumably the inverse. Oh, and there must have been an addition table, too.  We created tables by hand (on paper) so that we wouldn&#8217;t have to recalculate all the time; computers would&#8217;ve made this process much easier.<\/p>\n<p>Then we picked a four-character encryption key (I seem to recall we used the word BEAR in one test of the system), put the letters into a 2&#215;2 matrix, and put the plaintext into an nx2 matrix.  Like so:<\/p>\n<table>\n<tr>\n<td>\n<table>\n<tr>\n<td>B<\/td>\n<td>E<\/td>\n<\/tr>\n<tr>\n<td>A<\/td>\n<td>R<\/td>\n<\/tr>\n<\/table>\n<\/td>\n<td>\nX\n<\/td>\n<td>\n<table>\n<tr>\n<td>T<\/td>\n<td>E<\/td>\n<td>S<\/td>\n<td>T<\/td>\n<td>_<\/td>\n<td>M<\/td>\n<\/tr>\n<tr>\n<td>E<\/td>\n<td>S<\/td>\n<td>S<\/td>\n<td>A<\/td>\n<td>G<\/td>\n<td>E<\/td>\n<\/tr>\n<\/table>\n<\/td>\n<\/tr>\n<\/table>\n<p>Matrix multiplication produced the encrypted text.  The recipient would find the inverse of the BEAR matrix, and multiply it by the encrypted text to produce the plaintext again.<\/p>\n<p>I&#8217;m sure we only used this system half a dozen times, just for fun; it was a slow and painstaking process to encrypt and decrypt by hand.  I kept the tables for years, though (they&#8217;re probably still in a box in my garage), and knowing how to do matrix multiplication came in handy years later when it came up in math class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sorry for the long silence&#8211;was busy, then had to spend a bunch of time fixing some problems with the blog. All fixed now, I think. Welcome, Dobe! Thanks for posting! On my way home from work this evening, I suddenly remembered something I hadn&#8217;t thought of in years: at one point when I was a [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":1,"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/posts\/19\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kith.org\/peter\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}