Crypto Corner
  • Home
    • Crypto Corner Challenges
    • Glossary
    • Help with Activities
    • Educational Uses
    • Downloadable Resources
  • Introduction to Cryptography
    • Steganography
    • Codes and Ciphers
    • Conventions in Cryptography
  • Monoalphabetic Substitution Ciphers
    • Atbash Cipher
    • Pigpen Cipher
    • Caesar Shift Cipher
    • Affine Cipher
    • Mixed Alphabet Cipher
    • Other Examples
    • Frequency Analysis: Breaking the Code
    • Homophonic Substitution
  • Simple Transposition Ciphers
    • Rail Fence Cipher
    • Route Cipher
    • Columnar Transposition Cipher
    • Myszkowski Transposition Cipher
    • Permutation Cipher
    • Anagramming: Jumbling words
    • Combining Monoalphabetic and Simple Transposition Ciphers
  • Polyalphabetic Substitution Ciphers
    • Vigenère Cipher
    • Kasiski Analysis: Breaking the Code
    • Autokey Cipher
    • Other Examples
  • Fractionating Ciphers
    • Polybius Square
    • Straddling Checkerboard
    • Transposing Fractionated Text
    • Other ways to Alter Fractionated Text
  • Digraph Substitution Ciphers
    • Playfair Cipher
    • Two-Square Cipher
    • Four-Square Cipher
    • Hill Cipher

Two-Square Cipher

  1. Cipher Activity
  2. Introduction
  3. Encryption
  4. Decryption
  5. Discussion
  6. Exercise

The Two-Square Cipher is a more secure Digraph Substitution Cipher than the Playfair Cipher, and is somewhat less cumbersome than the Four-Square Cipher.
It is similar to both these ciphers in that it relies on forming rectangles where the plaintext  digraph form two of the corners of the rectangle, whilst the ciphertext digraph forms the other two corners. However, it is different from the Playfair Cipher in that it utilises two Mixed Squares adjacent to each other. In this way the main weaknesses of the Playfair Cipher are wiped out, as a letter can encrypt to itself, and you can have double letters appearing.
Encryption
To encrypt using the Two-Square Cipher you must first generate two Mixed Squares, preferably using two different keywords. These are places either one on top of the other, or next to each other (different results will be achieved depending on which you choose). Now you split the plaintext into digraphs (unlike the Playfair Cipher, it does not matter if a digraph is a repeated letter). For each digraph, you locate the first character within the top/left Mixed Square and the second character in the bottom/right Mixed Square. Create a rectangle where these two letters form opposite corners, and the ciphertext characters are the other two corners. Order is important: the plaintext letter is encrypted to the ciphertext letter that is in the SAME mixed square.
As an example we shall consider the plaintext "help me obi wan kenobi" with keywords example and keyword. We shall consider both variants simultaneously, with the vertical version to the left, and the horizontal version to the right.
In both versions, the first thing we need to do is generate the two Mixed Squares.
Picture
The vertical version of the mixed squares using keywords example and keyword
Picture
The horizontal version of the mixed squares using keywords example and keyword
Now we need to split our plaintext into digraphs.
Picture
The plaintext split into digraphs.
For the vertical version, for each digraph we find the first letter in the top square and the second letter in the bottom square. We then form the rectangle with these two points as corners. The ciphertext digraph is formed by taking the other corner in the top square as the first letter, and the other corner in the bottom square as the second letter.
For the horizontal version, for each digraph we find the first letter in the left square and the second letter in the right square. We then form the rectangle with these two points as corners. The ciphertext digraph is formed by taking the other corner in the left square as the first letter, and the other corner in the right square as the second letter.
This gives us the final ciphertext digraphs using the vertical version of the Two-Square Cipher.
Picture
The ciphertext digraphs when using the vertical version.
Giving us the final ciphertext "HECMXWSRKYXPHWNODG" or "HECM XW SRK YXP HWNODG" if we split it like the plaintext.
This gives us the final ciphertext digraphs using the horizontal version of the Two-Square Cipher.
Picture
The ciphertext digraphs when using the horizontal version.
Giving us the final ciphertext "XGOAMELQAIREMGPLHB" or "XGOA ME LQA IRE MGPLHB" if we split it like the plaintext.
Decryption
The method of decryption for the Two-Square Cipher is identical to the method of encryption due to the symmetric nature of the cipher. Firstly we must create the two Mixed Squares, and split the ciphertext into digraphs. Then we locate the first character of each digraph in the top/left square and the second character in the bottom/right square. By forming the rectangle with these two points as corners, the other corner in the top/left square is the first letter of the plaintext digraph, and the other corner in the bottom/right square is the second letter of the plaintext digraph.
Discussion
One thing to note in the vertical version of the encryption example above is that the first digraph "he" encrypted to itself "HE". This is because the two letters were in the same row and there were no other corners. In cryptography this is known as a transparency, and is actually something that ise useful in strengthening a cipher. One of the main weaknesses of many ciphers is that a character (or digraph) cannot be encrypted to itself, thus eliminating possibilities for the cryptanalyst to try. With the possibility of transparencies this weakness is removed. However, in the case of the Two-Square Cipher, since approximately 20% of digraphs will result in a transparency, this is actually a weakness.
A cryptanalyst would use this high percentage of transparencies in breaking an intercept, providing the message was long enough. If this is the case, then it is likely that at some point some transparencies would appear consecutively, and thus begin to reveal word fragments. From these, the cryptanalyst can work backwards to build the two mixed squares, and unravel other digraphs.

Previous Page: Playfair Cipher
Next Page: Four-Square Cipher
Information
  • About Me
  • Contact Me
  • Legal
  • Glossary
  • Help with Activities
  • Educational Uses
  • Downloadble Resources
Crypto Corner is a subsiduary of www.interactive-maths.com
©2013 - 2022 Daniel Rodriguez-Clark
All rights reserved
If you have found Crypto Corner useful, then please help to keep it a free site by donating using the button below. Thanks!
  • Home
    • Crypto Corner Challenges
    • Glossary
    • Help with Activities
    • Educational Uses
    • Downloadable Resources
  • Introduction to Cryptography
    • Steganography
    • Codes and Ciphers
    • Conventions in Cryptography
  • Monoalphabetic Substitution Ciphers
    • Atbash Cipher
    • Pigpen Cipher
    • Caesar Shift Cipher
    • Affine Cipher
    • Mixed Alphabet Cipher
    • Other Examples
    • Frequency Analysis: Breaking the Code
    • Homophonic Substitution
  • Simple Transposition Ciphers
    • Rail Fence Cipher
    • Route Cipher
    • Columnar Transposition Cipher
    • Myszkowski Transposition Cipher
    • Permutation Cipher
    • Anagramming: Jumbling words
    • Combining Monoalphabetic and Simple Transposition Ciphers
  • Polyalphabetic Substitution Ciphers
    • Vigenère Cipher
    • Kasiski Analysis: Breaking the Code
    • Autokey Cipher
    • Other Examples
  • Fractionating Ciphers
    • Polybius Square
    • Straddling Checkerboard
    • Transposing Fractionated Text
    • Other ways to Alter Fractionated Text
  • Digraph Substitution Ciphers
    • Playfair Cipher
    • Two-Square Cipher
    • Four-Square Cipher
    • Hill Cipher