[image of digits]

Cryptology
The origins of the modern computer have their foundations in cryptographic and cryptanalytic activities during the second world war.
Visit our other page on Cryptology for more information.

Transposition Ciphers
Reorder the letters in a message in a seemingly random way.

The Turning Grille - "Apparatus for Cypher Correspondence" Patented #1163, 1875. Click on any image for an enlargement. (The letter "b" in the diagram simply represents a hinge.)

The circular holes are cut out of the card. The message is written, one letter in each hole, until all the holes are filled. The card is then turned clockwise ninety degrees and the message is continued. The card may be turned four times to completely fill the 14 by 14 cell grid. Note the turning guide (the Roman numerals) in the lower right hand corner.

@@ @@ @@

An Enigma Machine Simulator

This fantastic simulator was written by Dirk Rijmenants
and is available, among others, for free download from his Website:

http://users.telenet.be/d.rijmenants/en/enigmasim.htm

Most substitution ciphers are simple additive shifts from a cleartext to a cryptotext alphabet.
The shifts may change with each letter, group of letters or each message.

A Centimeter Scale
to add two lengths, we physically add the lengths to one another...
(the images are slightly distorted so don't expect great accuracy)

A "Slide Rule"
to multiply two numbers we simply add their logarithms

(the images are slightly distorted so don't expect great accuracy)

  1. Set the "1" on the "C" scale over the first factor on the "D" scale.
  2. Read along the "C" scale to the second factor.
  3. The product will be directly below it on the "D" scale.

A "Cryptologic Slide Rule"
to encrypt, we shift the clear alphabet to get the cipher alphabet
(the cleartext or plaintext is often shown in lower-case, the ciphertext or cryptotext in upper-case)

French silver polyalphabetic substitution cipher disk by Nicolas Bion (1652-1733).

Executable - Source Code - Zipped Project File


Maker of mathematical instruments to King Louis XV.

It seems likely that the progression served as a keying method:
Rotating the
BLUE inner disk so that it's number "1" aligned with the number "1" on the RED outer disk (which served as an index) gives the first alphabet for keying.
Rotating the
BLUE inner disk so that it's number "2" aligned with the number "1" on the RED outer disk (which served as an index) gives the second alphabet for keying.
Rotating the
BLUE inner disk so that it's number "3" aligned with the number "1" on the RED outer disk (which served as an index) gives the third alphabet for keying.
If we continued this, using a separate alphabet for each letter in the cleartext, we would have a key of length 24 letters.
Using the convention that "A" on the
BLUE inner disk serves as an index, and points to the indicator on the RED outer disk, we get this progression or key:
CEDAB YZWXT SVPRQ MNOKL FHGI
Using the convention that "A" on the
RED outer
disk serves as an index, and points to the indicator on the BLUE inner disk, we get this progression or key:
YWXAZ CBEDG HELIK ONMQP VSTR

We could then repeat the key, but shifted, in the following manner:
Rotating the BLUE
inner disk so that it's number "1" aligned with the number "2" on the RED outer disk (which served as an index) gives the twenty-fifth alphabet for keying.
Rotating the
BLUE inner disk so that it's number "2" aligned with the number "2" on the RED outer disk (which served as an index) gives thetwenty-sixth alphabet for keying.
Rotating the
BLUE inner disk so that it's number "3" aligned with the number "2" on the RED outer disk (which served as an index) gives thetwenty-seventh alphabet for keying.
If we continued this, we would now have a key of length 576 letters.
The close clustering of the progression on the
BLUE
inner disk would serve to simplify its manipulation.
The initial irregularity of the RED
outer disk would serve to hide its function as an index.

In a similar manner we could do the inverse, but it would not produce as irregular a key:
Rotating the
RED outer disk so that it's number "1" aligned with the number "1" on the BLUE inner disk (which served as an index) gives the first alphabet for keying.
Rotating the
RED outer disk so that it's number "2" aligned with the number "1" on the BLUE inner disk (which served as an index) gives the second alphabet for keying.
Rotating the
RED outer disk so that it's number "3" aligned with the number "1" on the BLUE inner disk (which served as an index) gives the third alphabet for keying.
And so on...
Using the convention that "A" on the
BLUE inner disk serves as an index, and points to the indicator on the RED outer disk, we get this progression or key:
CYZAB SDEFG HIKLM NOPQR STVW
Using the convention that "A" on the
RED outer
disk serves as an index, and points to the indicator on the BLUE inner disk, we get this progression or key:
YCBAZ DXWVT SRQPO NMLKI HGFE
Unlike the previous method, this keying system is largely regular, mostly shifting the disk clockwise or anticlockwise one step at a time.

Is this too complicated a procedure? Alberti suggested using a short key in the 1400s. The Rossignols were practised in cryptanalysis. By comparison, this procedure is relatively simple.

Evocrypt - A monoalphabetic substitution cipher cryptanalyzer

XE6 EvoCrypt - Adaptation by Trey Bagley -021 April 2015
Enter a cryptotext (you can input the one that appears by default), open the two dictionaries and begin the run(s). 100 runs of 100 generations will complete in one minute. 100 runs of 1000 generations will complete in 17 minutes. You can help this evolutionary algorithm by locking in specific Cryptext to Cleartext characters. This application scores a substitution alphabet on the valid words it produces, but how? By their frequency, length or number? How might that change if the scores were based on n-grams which included blank spaces, sub-words, word pairing and/or grammar?

Lock in the second and third words as "we are."

Lock "H" to "e"
Lock "K" to "w"
Lock "P" to ""a"
Lock "X" to "r"

With those locked in, 100 runs of 500 generations will produce interesting results in a short time!

The Vernam Polyalphabetic Substitution Cipher using a One-Time-Key

An ASCII Code Chart

ASCII / Decimal / Byte Conversions

An illustration of how to pull individual bits out of an ASCII character and how to construct an ASCII character from individual bits. If we are to distribute ASCII code among pixels without changing their values by more than one, we will need to manipulate single low-order bits.

A Vernam Cipher (2012) utilizing all 94 printable ASCII characters
(do not use "<" or ">")

A "key" to understanding many cipher systems is to think of each character in a text as a number in ASCII order. Encryption and decryption then become an easy task of adding or subtracting these numbers, one at a time (with no carry over) using the simple equation:
Clear + Key = Cipher

Why usenumbers? The answer is relatively simple. Think of the addition as an offset on a slide rule, such as the linear slider rule above. The slide rule is simply a device to add logarithms, so it may easily be used to solve cryptograms as well.
What do we do with negative numbers or numbers higher than the highest one? Again, the answer is simple, we use modular arithmetic. It is the remainder of dividing the number by the number possible enciphered symbols. Perhaps it is easier to visualize this with a circular slide rule which accomplishes the same thing by wrapping the sequence around itself endlessly.
Using a completely random key only once for any message, the system is unbreakable.

Texts must be entered in the white boxes using any of the printable ASCII characters, including numerals, spaces and punctuation (but no up or down arrows and no carraige-returns, tabs, or other control characters). Texts will remain gray until they are Entered into the converter, whereupon they will turn black. When text in any two boxes is Entered, text for the remaining box may be Extracted. The numeric values of the text characters (modified from ASCII) are shown in the gray box below.

Although this messages looks like cleartext, it is, in fact, a cipher:
Hope you are well this morning.
Two different informants provide you with two different keys:
hwxeg wmnrl sleht vhsuw rkuwj
facyh obgge dasep hwrmw znfzp

Which is the correct key?
What does this tell you about the security of the system?

A Vernam Cipher (2012) utilizing only lowercase ASCII letters

A "key" to understanding many cipher systems is to think of the alphabet, in alphabetical order, as a sequence of numbers from a = 0 through z = 25. Encryption and decryption then become an easy task of adding or subtracting these numbers, one number (character) at a time (with no carry over) using the simple equation:
Clear + Key = Cipher


Why use a = 0 through z = 25 instead of a = 1 through z = 26? The answer is relatively simple. Think of the addition as an offset on a slide rule, such as the linear slider rule above. The slide rule is simply a device to add logarithms, so it may easily be used to solve cryptograms.
One more issue: What do we do with negative numbers or numbers higher than 25? Again, the answer is simple, we use arithmatic modulo 26. That is to say, the number below zero is 25 and the number above 25 is zero. It is the remainder of dividing the sum by 26. Perhaps it is easier to visualize this with a circular slide rule which accomplishes the same thing by wrapping the sequence around itself, like a snake with its tail in its mouth, endlessly.
Using a completely random key only once for any message, the system is unbreakable.

Texts must be entered in the white boxes using all lower-case letters and no spaces or punctuation. Texts will remain gray until they are Entered into the converter, whereupon they will turn black. When text in any two boxes is Entered, text for the remaining box may be Extracted. The numeric values of the text characters (a = 0 through z = 25) are shown in the gray box below. There is no reason why the entire ASCII character set may not be treated in this manner; however, for simplicity this application uses the old tradition of allowing for only lower-case letters and no white-space.

Only use bitmap (.bmp) images.
There should be enough code in the applications on this page to complete this project.

A Hybrid Steganographic Image Vernan Cipher (unfinished)

This application is an extension of the one-time-key (Vernan Cipher) which accepts any printable character (view a Modified ASCII Code Chart), unlike the previous example which only accepts lower-case letters. It provides MemoBoxes for Clear, Key and Cipher texts as before. The idea is to use the low-order bits of pixels in an "innocent" Key Image downloaded from the Web (maybe something from CNN). To encript and hide a message, the user would first import what will become a Cipher Image which she wil post inconspicously on the Web (maybe as an eBay auction item). She will then unembed the the pattern in the Key Image to produce the Key Text. Next type and ENTER the Clear Text, which along with the Key Text will enable her to EXTRACT the Cipher Text. Finally she will embed the Cipher Text in the Cipher Image and then post it on the Web. Of course, the sender and receiver of the message must both agree on where to find the two images. Given the vast number of images on the Web, it will be inordinately difficult to discover which two images are being used, since neither one contains any tell-tale regularities.

A Clear Image is included to demonstrate the embedding of Clear Test in an image without encipherment. This, of course, is a much less secure alternative

U.S. Army Cipher Device M-94

Decipher this:
LTMSX VQPNO HUWDI ZYCGK RFBEJ
ZDZIA TAYHW AYBMU PIXTQ WBTKC

Note: ("to" -> "too")

U.S. Army Cipher Device M-94

A simulation of an actual field cipher device used for tactical messages prior to, and periodically during the Second World War. There are 25 different disks, numbered from 1 to 25 and given letter designations from B - Z. They can be placed on the spindle in any order. Each disk (rotor) contains the alphabet scrambled in a different sequence. You can change the order of the disks as well as rotate them into different positions. To encode a message, place the disks in a predetermined order and set the cleartext on any line. Then read any other line as the ciphertext. To decode, place the disks in the same predetermined order and set the ciphertext on any line. Then look for any other line that is intelligible.

AN EVOLUTIONARY DECRYPTION of a cyphertext might be found by modifying the Evolutionary Concert Tour application. The two systems are analogous: Finding the correct cleartext is a matter of finding the "fittest" (c.f. "shortest") arrangement of the 25 disks (c.f. "path through the 30 cities). The fitness of any disk order might be measured by the comparing the letter frequency of each line of text in that disk order to that of standard English. One might then choose the closest match as the fitness of that disk order. In this way we might be able to evolve a solution to the cyphertext.

Hiding Text in Images

Since the bitmap (.bmp) is the simplest uncompressed image file format, it should also be the simplest image format in which to hide text, making our programming efforts a little easier. Some drawbacks are that the file sizes are enormous and that bitmaps are not universally supported by Web browsers and Operating Systems. All works well with Windows and Internet Explorer, Chrome and Firefox.

Clearly, the first step documented below is hardly hidden, but it does demonstrate a pixel interpretation of ASCII text. Not surprisingly, since ASCII characters range from 0-127, and the red, green and blue primaries range from 0-255, the colors of the ASCII characters are dark. So any image containing such a randomly dark texture is a dead give-away that there is text inside.

We note that there is one piece of software offered for sale on the Web that hides text in images using a password. However, the image files grow by the size of the text and password added. Again, any image file that is substantially larger than it should be is a dead give-away that there is text hidden inside.

A Tribute to Herbert O. Yardley
borrowed from the superb
National Cryptologic Museum.

This exhibit details the checkered career of Herbert O. Yardley (1889-1958), who headed the highly secret MI-8, or the "Black Chamber." Yardley began his career as a code clerk with the U.S. State Department, and during that service discovered his natural talent as a cryptanalyst. During World War I, Yardley served in the cryptologic section of Military Intelligence (MI) with the American Expeditionary Forces. After the war, Yardley lead the first peacetime cryptanalytic organization in the United States, MI-8. Funded by the Army and the State Department, MI-8, was disguised as a New York City company that made commercial codes for businesses. However, their actual mission was to break the diplomatic codes of different nations. A mission they were initially quite successful at completing, breaking codes from several foreign countries. MI-8 had an early success: in 1921-22, Yardley and his staff solved the cipher system used by Japanese negotiators at the Washington Naval Conference. They fed the decrypts to the U.S. chief negotiator, Charles Evans Hughes. The messages contained the Japanese’s minimum demands at the conference. Hughes appeared to be outsmarting the Japanese to obtain a more favorable agreement on naval capital ships, when actually he was reading their negotiating position every day before he went into the bargaining sessions. In 1929, the State Department closed down MI-8. According to legend, Secretary of State Henry Stimson at that time spoke the famous sentence: “Gentlemen do not read each other’s mail.” Disappointed, unemployed, and accustomed to luxury, Yardley found himself in need of finances and in possession of his country’s secrets. He wrote The American Black Chamber, which revealed to the world the work of MI-8. It became an international best seller. Needless to say, the Army, which continued codebreaking, was not amused. And the Japanese, for their part, changed their code systems. Surprisingly, at the time, the wording of the espionage laws contained a loophole that prevented the government from prosecuting Yardley. Yardley, a brilliant cryptanalyst, as well as a promoter of the cryptologic cause, continued to provide expertise to various countries, but never again worked for the United States.

Herbert O. Yardley

A .jpg image.
Size is 21,044 bytes.

Herbert O. Yardley

A .bmp image.
Size is 91,256 bytes.

Herbert O. Yardley

A .bmp image with the text at left inserted at the bottom of the .bmp file using SynEdit. The text appears at the top of the image as a somewhat random texture.
Size is 91,256 bytes.

An enlargement of the top of the image of Yardley showing the inserted text rendered as red, green and blue color triplets (pixels).

A portion of the bitmap (.bmp) image file with text inserted as seen in the binary/hexadecimal SynEdit editor.

The division between true pixel triplets and ASCII text is delineated in red.

Let's dissect a six-by-six pixel bitmap image, shown here as a .jpg but actual size:

x

Let's blow up the six-by-six pixel image to 100 by 100 pixels so we can see it clearly:

x

In Hex Editor, the hexadecimal code is shown in the left column, the ASCII equivalent (if there is any) in the right:

Below is one annotation of the complete file as viewed in SynEdit's Hex Editor.

x

Below is another annotation of the complete file as viewed in SynEdit's Hex Editor:

x

Some resources for file formats:

Wotsit's Format - The programmer's resource.
http://www.wotsit.org/

Every file format in the world.
http://whatis.techtarget.com/fileFormatA/0,289933,sid9,00.html

ASCII, HEX, OCTAL and other charts and resources.
http://www.jimprice.com/jim-asc.htm