The Four-Square Cipher is a substitution cipher that encrypts pairs of letters at a time. The cipher is represented by four 5x5 grids. Two keywords are used to create ciphertext squares, and the other grids are filled with the plaintext alphabet. To make the alphabet fit, the cipher either combines I and J into one letter, or removes Q from the alphabet (Our implementation does the latter). The position of the two letter in a plaintext pair is used to determine the ciphertext letters that replace them; this is done by creating a rectangle with the plaintext letters as two corners, and using the letters at the other corners as the ciphertext letters (See the example below). Decoding the message simply reverses the process.
The Four-Square cipher is more secure than a substituion cipher that encrypts single letters at a time, since there are 676 possible pairs of letters to look for instead of 26 possible single letters. However, it can still be broken if there is enough text to analyze.
Learn more about Four-Square ciphers here.