Two-Square Cipher Encryption and Decryption

Plaintext
Ciphertext
12345
1EXAMP
2LBCDF
3GHIJK
4NOQRS
5TUVWY
12345
1KEYWO
2RDABC
3FGHIJ
4LMNPQ
5STUVX

What is the Two-Square Cipher?

The Two-Square Cipher is a substitution cipher that primarily utilizes two independent letter square grids for encryption and decryption. Unlike traditional single-square ciphers, such as the Playfair Cipher, the use of two grids increases the complexity of encryption, making it harder to decrypt without the correct key.

Differences Between Two-Square Cipher and Playfair Cipher

FeatureTwo-Square CipherPlayfair Cipher
Number of SquaresUses two independent letter squares, each generated from a separate key, to encrypt each pair of letters.Uses only one letter square, typically a 5×5 grid, generated from a single key, where all letters (or a combination of letters and numbers) are placed.
Encryption MethodFor each pair of letters, the positions (row and column) in two different squares are located, and the letters are replaced based on their positional relationship.For each letter, its position in the single square is used for replacement.
SecurityWith two separate keys and grids, the security is stronger. Even if one grid is compromised, the other grid remains secure.The single square method is simpler and easier to crack because it only requires analysis of the letter arrangement in one grid.
Decryption ProcessDecryption requires using both grids, extracting letters based on their original positions, and reversing the operations (such as extracting letters by rows or columns) to recover the plaintext.Decryption uses the same grid, and letters are restored through reverse transformation.

How Does the Two-Square Cipher Encrypt?

The encryption process involves several steps:

  1. Prepare the Plaintext: Remove any non-letter characters, and split the plaintext into pairs of letters.
  2. Set Up Two Keys: The Two-Square Cipher requires two distinct keys, each used to generate a separate 5×5 letter grid. The alphabet letters are placed into the grid, removing duplicates. The remaining positions are filled in sequence with the unused letters of the alphabet.
  3. Divide the Plaintext into Letter Pairs: Break the plaintext into pairs of two letters (e.g., "HELLO" becomes "HE", "LL", "OX"). If the number of letters is odd, append a filler letter at the end (e.g., "X").
  4. Replace the Letters: For each pair, find the positions of the two letters in both grids. The row and column positions form a rectangle, and the diagonal letters of this rectangle are used to replace the original pair.
  5. Generate the Ciphertext: Apply the above replacement process to all plaintext pairs to obtain the ciphertext.

Example

Suppose we use the keys "MONARCHY" and "BIPINXDFGKL" to encrypt the word "HELLO".

1. Generate the Grids Based on the Keys

MONAR
CHYBD
EFGIJ
KLPQS
TUVWX
BIPNX
DFGKL
ACEHJ
MOQRS
TUVWY

2. Divide the Plaintext into Pairs

"HELLO" becomes "HE", "LL", and "OX" (because "HELLO" has an odd number of letters, "O" is followed by "X").

3. Replace the Letters

So, the ciphertext for "HELLO" is: "YCSFRI".

How Does the Two-Square Cipher Decrypt?

The decryption process is exactly the reverse of encryption, where each step is undone using the reverse replacement procedure to recover the plaintext.

Example

To decrypt "YCSFRI" using the keys "MONARCHY" and "BIPINXDFGKL":

1. Divide the Ciphertext into Pairs

"YCSFRI" becomes "YC", "SF", and "RI".

2. Replace the Letters

Thus, the plaintext for "YCSFRI" is: "HELLOX".

Share This Page