TwoSquare Cipher
The TwoSquare Cipher is a more secure Digraph Substitution Cipher than the Playfair Cipher, and is somewhat less cumbersome than the FourSquare 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 TwoSquare 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.
To encrypt using the TwoSquare 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.
Now we need to split our plaintext 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 TwoSquare Cipher.
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 TwoSquare Cipher.
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 TwoSquare 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.
The method of decryption for the TwoSquare 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 TwoSquare Cipher, since approximately 20% of digraphs will result in a transparency, this is actually a weakness.
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 TwoSquare 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.