Science Fair Projects Ideas - Two-square cipher

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Two-square cipher

The Two-square cipher is a manual symmetric encryption technique. It was developed to ease the cumbersome nature of the large encryption/decryption matrix used in the four-square cipher while still being slightly stronger than the Playfair cipher.

The technique encrypts pairs of letters (digraphs), and thus falls into a category of ciphers known as polygraphic substitution ciphers . This adds significant strength to the encryption when compared with monographic substitution ciphers which operate on single characters. The use of digraphs makes the two-square technique less susceptible to frequency analysis attacks, as the analysis must be done on 676 possible digraphs rather than just 26 for monographic substitution. The frequency analysis of digraphs is possible, but considerably more difficult - and it generally requires a much larger ciphertext in order to be useful.

Using two-square

The two-square cipher comes in two varieties - horizontal and vertical. The vertical two-square uses two 5 by 5 matrices one above the other. The horizontal two-square has the two 5 by 5 matrices side by side. Each of the 5 by 5 matrices contains the letters of the alphabet (usually omitting "Q" or putting both "I" and "J" in the same location to reduce the alphabet to fit). The alphabets in both squares are generally mixed alphabets , each based on some keyword or phrase.

To generate the 5 by 5 matrices, one would first fill in the spaces in the matrix with the letters of a keyword or phrase (dropping any duplicate letters), then fill the remaining spaces with the rest of the letters of the alphabet in order (again omitting "Q" to reduce the alphabet to fit). The key can be written in the top rows of the table, from left to right, or in some other pattern, such as a spiral beginning in the upper-left-hand corner and ending in the center. The keyword together with the conventions for filling in the 5 by 5 table constitute the cipher key. The two-square algorithm allows for two separate keys, one for each matrix.

As an example, here are the veritcal two-square matrices for the keywords "example" and "keyword:"

E X A M P
L B C D F
G H I J K
N O R S T
U V W Y Z
 
K E Y W O
R D A B C
F G H I J
L M N P S
T U V X Z

Encryption using two-square is basically the same as the system used in four-square, except that the plaintext and ciphertext digraphs use the same matrices. For a vertical two-square, the first character of both digraphs uses the top matrix, while the second character uses the bottom. For a horizontal two-square, the first character of both digraphs uses the left matrix, while the second character uses the right. A rectangle is defined by the two plaintext characters and the opposite corners define the ciphertext digraph.

Using the vertical four-square example given above, we can encrypt the following plaintext:

Plaintext:  he lp me ob iw an ke no bi
Ciphertext: HE DL XW SD JY AN HO TK DG

Here is the same two-square written out again but blanking all of the values that aren't used for encrypting the digraph "ME" into "XW"

- X - M -
- - - - -
- - - - -
- - - - -
- - - - -
 
- E - W -
- - - - -
- - - - -
- - - - -
- - - - -

The rectangle rule used to encrypt and decrypt can be seen clearly in this diagram. The method for decrypting is identical to the method for encryption.

Just like Playfair (and unlike four-square), there are special circumstances when the two letters in a digraph are in the same column for vertical two-square or in the same row for horizontal two-square. In vertical two-square, a plaintext digraph that ends up with both characters in the same column gives the same digraph in the ciphertext. In cryptography this is referred to as a transparency. Notice in the above example how the digraphs "HE" and "AN" mapped to themselves. A weakness of the vertical two-square is that about 20% of digraphs will be transparencies.

In horizontal two-squares, plaintext digraphs that end up with both characters in the same row give the reversed digraph in the ciphertext (e.g. AB goes to BA). This is referred to as a reverse transparancy. Reverse transparancies appear for about 20% of digraphs in horizontal two-squares. The high frequency of transparencies for both types of two-squares severly weaken the system.

Two-square cryptanalysis

Like most pre-modern era ciphers, the two-square cipher can be easily cracked if there is enough text. Obtaining the key is relatively straightforward if both plaintext and ciphertext are known. When only the ciphertext is known, brute force cryptanalysis of the cipher involves searching through the key space for matches between the frequency of occurrence of digrams (pairs of letters) and the known frequency of occurrence of digrams in the assumed language of the original message.

Cryptanalysis of two-square almost always revolves around the transparency weakness. Not knowing whether a horizontal or vertical two-square was used means that either the ciphertext or the reverse of the ciphertext will show a significant amount of plaintext fragments. In a large enough ciphertext sample, there is likely to be several transparent digraphs in a row and should be recognizeable. From these word fragments the analyst can generate candidate plaintext strings and work backwards to the keyword.

A good tutorial on reconstructing the key for a two-square cipher can be found in chapter 7, "Solution to Polygraphic Substitution Systems," of Field Manual 34-40-2, produced by the United States Army.

See also: Topics in cryptography
Last updated: 05-25-2005 18:57:18
10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice