Article content

Encrypt text like Robert Patterson - an explanation and a demonstration of the Patterson cipher

A cipher which for 200 years was considered to difficult and obscure to crack, was recently done in by Lawren Smithline, a 36-year-old mathematician and professional cryptologist. Now input your own text and have it encrypted the same way that mathematician Robert Patterson did when he sent his letter to President Thomas Jefferson in 1801.

Two centuries ago, Robert Patterson a mathematics professor at the University of Pennsylvania, sent a letter to Thomas Jefferson. Both men were members of the American Philosophical Society and frequently wrote to each other. In December 1801 Mr. Patterson sent a letter to the President to show him what he deemed to be a nearly flawless cipher. Permalink for this article http://mirror.magicode.org/content/Encrypt_text_according_to_Robert_Pattersons_letter_to_Thomas_Jefferson

"The art of secret writing," or writing in cipher, has "engaged the attention both of the states-man & philosopher for many ages," Mr. Patterson wrote. But, he added, most ciphers fall "far short of perfection." This text was originally written for http://blog.magicode.org

In Mr. Pattersons view, a perfect code should have the following properties:

  1. It should work in any language.
  2. It should be easy to memorize.
  3. It should be simple to perform.
  4. It should be indecipherable to anyone who doesn’t have the key.
If you see this notice on any site other than magicode.org, it's probably been lifted without consent

Pattersons example of a perfect encrypted text The fourth requirement was especially important to Patterson and to demonstrate he included a cipher which he said would “defy the united ingenuity of the whole human race to decypher to the end of time”. The trick to solving the puzzle, Mr. Patterson explained in his letter, meant knowing the following: the number of lines in each section, the order in which those lines were transcribed and the number of random letters added to each line.

There is no evidence that anyone ever solved the code at the time, but it finally met its match in Lawren Smithline, a 36-year-old mathematician who works professionally with cryptology at the Center for Communications Research in Princeton, N.J. Dr. Smithline revealed the hidden text in 2007, and recently wrote about how he deciphered the code in in the magazine American Scientist and also in a profile in Harvard Magazine.

Dr. Smithline cracked the code by analyzing the probability of digraphs, or pairs of letters. Certain letter pairs always appears next to certain other letters, like 'u' after 'q', while some letter pairs don't exist at all in proper English, like "dx". Dr. Smithline made a series of educated guesses and used a computer tool called “dynamic programming,” which solves large problems by breaking puzzles down into smaller pieces and linking together the solutions.

After about a week of working on the puzzle, Dr. Smithline found the key to Mr. Patterson's cipher -- 13, 34, 57, 65, 22, 78, 49. Using that key, he was able to reveal the hidden text, which was as follows:
In Congress, July Fourth, one thousand seven hundred and seventy six. A declaration by the Representatives of the United States of America in Congress assembled. When in the course of human events it becomes necessary for one People to dissolve Political Bands which have connected them with
Which is a play on the beginning of the Declaration of Independence. President Jefferson was the primary author of the declaration.

Here's how it works


Enter a text below and you'll end up with something that looks like the text in box 1. Using Patterson's cipher key (13, 34, 57, 65, 22, 78, 49), we can remove the random numbers added to the sentences. All spaces and all numeric and non-letters are removed, so numbers must be spelled out with letters, which is why Patterson wrote one thousand seven hundred and seventy six instead of 1776.

You'll notice that Patterson's cipher key consists of seven digit pairs, so we divide the text to decipher in blocks of seven sentences. In 3, the random letters are removed, and again using the cipher key, we reorder the lines.

In 4, the text is readable vertically, the first few words being 'defy the..', and so on. Patterson added an unspecified number of random letters in each sentence, and these remain. To make decoding of this text fully automatic, we would need a third digit in the cipher key to let us know how many letters are added.

Now you can try your hand at encrypting your own text based on Robert Patterson's cipher. Try entering a sentence in the textbox below and click on the button marked 'Encrypt'. Since we're operating in seven blocks pr. cipher, you need to enter a complete sentence, or else the encryption will return a generic error.


Automatic decryption

Here is a method for decrypting the data:


Discussion

Submit your comment

Text:

Your name:

Your email:

Show my mailaddress (spam protected)

Your website:

Show my website

Featured Article

PHP Variables and strings

A variable is a means of storing a value, such as a text string or a number. In PHP you do not have to declare your variable, as it's automatically declared when you set it. Since you do not need to declare the variable, you do not have to specify what kind of data it contains either.

Topics
Magicode's own open source project
From the forum / Latest comments
You may also want to to check out these links: sendanonmail.com, superstrongpassword.com.