Some years after Alexander Hamilton died (1804) from the wound he received in a duel with Aaron Burr, a packet containing instructions of a cipher was found among his papers. The endorsement states it was forwarded to Hamilton on 23 May 1803. (As to the origin of the document, see the editors' notes in The Papers of Alexander Hamilton.)
The method described in the document is what is known as a rotating grille or a turning grille. It was popular at the end of the eighteenth century, notably after C. F. Hindenburg first provided a complete description of the scheme in 1796 (Karl de Leeuw, Cryptology and Statecraft in the Dutch Republic, p.111).
A grille is a sheet with a grid of squares thereon. Some of the squares are cut out. The figure below shows a procedure to encipher a phrase "The Lord is my shepherd. I shall not be in want." with such a grille.
In this example, the grille has a 6-by-6 grid of squares, of which nine are cut out. To begin with, the first nine letters of the phrase (t, h, e, l, o, r, d, i, s) are one by one written in each square cut out, from left to right, top to bottom. Then, the grille is turned by ninety degrees in a predetermined direction (counterclockwise in this example). Then, the next nine letters (m, y, s, h, e, p, h, e, r) are written similarly. After the steps of turning the grille and writing the subsequent nine letters are repeated two more times, every square is filled by exactly one letter.
Copying the letters written from left to right, top to bottom, the following ciphertext is obtained:
A recipient should have the same grille as the one used in enciphering. Knowing the grille is 6-by-6, the decipherer copies the enciphered message in a 6-by-6 grid of squares of the same size as the grille:
Applying the grille, the recipient would read the first nine letters (t, h, e, l, o, r, d, i, s) through the cut out squares. After turning the grille by ninety degrees, the next nine letters can be read, and so on.
It is noted that, when enciphering, every time the grille is turned, the cut out squares are precisely positioned at squares not yet filled. To achieve such a feat, the squares of the grille to be cut out should be carefully chosen. The figure below shows a procedure for that.
First, the grid of squares is divided into four 3-by-3 quadrants. The nine squares of each quadrant are numbered 1-9 in a corresponding manner. Then, among the four squares numbered "1", one is selected to be cut out. In the above example, the rightmost square of the top row is cut out. This ensures that each of the four squares numbered "1" is exposed exactly once during enciphering by this particular cut-out square. Similarly, one of the four squares numbered "2" is selected to be cut out. By choosing thus exactly one square to be cut out from among the four squares bearing the same number, it can be ensured that each square can be filled at one of the four rotating positions.
A 6-by-6 grille may be too small to be used for messages in practice. The rotating grille for Hamilton contained 26-by-26 squares.
The instructions (in French) read as follows (the present author's translation).
Some other codes and ciphers by and for Hamilton are known, though the repertory was far less extensive than that of Thomas Jefferson or John Jay, who experienced foreign missions.
From 1792 to 1794, Hamilton's friend Gouverneur Morris, staying in Europe since 1789, was US minister residing in France. When Morris learned of his appointment, he wrote to Hamilton and proposed mutual confidential communication. Hamilton had a cipher devised and, for the time, proposed substitution of Roman names for some political figures.
In June 1799, Hamilton received from his father-in-law, General Philip Schuyler, "a lengthy and complex code system using Entick's Spelling Dictionary" (Weber p.146 n.9).
In 1800, Hamilton was preparing a cipher for correspondence with Rufus King, then US minister in London.