Four-Square Cipher

Keysquare 1
Keysquare 2

Four-Square Cipher is a manual symmetric encryption technique. It was invented by the French cryptographer Felix Delastelle.

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 four-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. [Wikipedia]


The Four-Square Cipher uses four 5 by 5 (5x5) matrices arranged in a square. 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). In general, the upper-left and lower-right matrices are the "plaintext squares" and each contain a standard alphabet. The upper-right and lower-left squares are the "ciphertext squares" and contain a mixed alphabetic sequence.

To generate the ciphertext squares, 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 four-square algorithm allows for two separate keys, one for each of the two ciphertext matrices.

As an example, here are the four-square matrices for the keywords "example" and "keyword." The plaintext matrices are in lowercase and the ciphertext matrices are in caps to make this example visually more simple:

a b c d e   E X A M P
f g h i j   L B C D F
k l m n o   G H I J K
p r s t u   N O R S T
v w x y z   U V W Y Z
 
K E Y W O   a b c d e
R D A B C   f g h i j
F G H I J   k l m n o
L M N P S   p r s t u
T U V X Z   v w x y z

How it works?

  1. Break up the plaintext into bigrams i.e. ATTACK AT DAWN --> AT TA CK AT DA WN. An 'X' (or some other character) may have to be appended to ensure the plaintext is an even length.

  2. Using the four 'squares', two plain alphabet squares and two cipher alphabet squares, locate the bigram to encrypt in the plain alphabet squares. The example below enciphers the bigram 'AT'. The first letter is located from the top left square, the second letter is located in the bottom right square.

    a b c d e   Z G P T F
    f g h i k   O I H M U
    l m n o p   W D R C N
    q r s t u   Y K E Q A
    v w x y z   X V S B L
     
    M F N B D   a b c d e
    C R H S A   f g h i k
    X Y O G V   l m n o p
    I T U E W   q r s t u
    L Q Z K P   v w x y z
    
  3. Locate the characters in the ciphertext at the corners of the rectangle that the letters 'AT' make:

    a b c d e   Z G P T F
    f g h i k   O I H M U
    l m n o p   W D R C N
    q r s t u   Y K E Q A
    v w x y z   X V S B L
     
    M F N B D   a b c d e
    C R H S A   f g h i k
    X Y O G V   l m n o p
    I T U E W   q r s t u
    L Q Z K P   v w x y z
  4. Using the above keys, the bigram 'AT' is encrypted to 'TI'. The text 'attack at dawn', with the keys 'zgptfoihmuwdrcnykeqaxvsbl' and 'mfnbdcrhsaxyogvituewlqzkp', becomes:

ATTACKATDAWN
TIYBFHTIZBSY
Morse code is a system of communication that uses two different signal durations, called dots and dashes, to encode text characters. It was invented by Samuel F.B. Morse in the 1830s and became widely used for telegraphy, the transmission of messages over long distances by electric wires.

Morse Code

Morse code is a system of communication that uses two different signal durations, called dots and dashes, to encode text characters. It was invented by Samuel F.B. Morse in the 1830s and became widely used for telegraphy, the transmission of messages over long distances by electric wires.
SHA encryption is a term that refers to a family of cryptographic hash functions that are used to verify the integrity and authenticity of data. A hash function is a mathematical function that takes an input and produces a fixed-length output, called a hash or a digest, that is unique for each input. SHA encryption can be used to generate digital signatures, checksums, passwords and other security applications.

SHA Encrypt

SHA encryption is a term that refers to a family of cryptographic hash functions that are used to verify the integrity and authenticity of data. A hash function is a mathematical function that takes an input and produces a fixed-length output, called a hash or a digest, that is unique for each input. SHA encryption can be used to generate digital signatures, checksums, passwords and other security applications.
​PBKDF2 Encryption is a specific type of Password-Based Key Derivation Function Encryption (PBKDF Encryption) that uses a pseudorandom function, such as hash-based message authentication code (HMAC), to generate a derived key from a password or a passphrase

PBKDF2 Encrypt

​PBKDF2 Encryption is a specific type of Password-Based Key Derivation Function Encryption (PBKDF Encryption) that uses a pseudorandom function, such as hash-based message authentication code (HMAC), to generate a derived key from a password or a passphrase
Symmetric Encrypt & Decrypt Online Tool is a web online tool that allows you to encrypt and decrypt text using symmetric encryption algorithms such as AES, Triple DES and DES. Symmetric encryption is widely used for data protection, authentication and digital signatures.

Symmetric Encrypt & Decrypt

Symmetric Encrypt & Decrypt Online Tool is a web online tool that allows you to encrypt and decrypt text using symmetric encryption algorithms such as AES, Triple DES and DES. Symmetric encryption is widely used for data protection, authentication and digital signatures.