ου γαρ εστιν κρυπτον ο ου φανερον γενησεται ουδε αποκρυφον ο ου γνωσθησεται και εις φανερον ελθη

# Simple substitution ciphers

• Description
• Algorithm
• Implementation
Simple substitution ciphers replace each plaintext letter by another one character. The transformation is unequivocal and reversible.
Simple substitution ciphers
Early simple substitution ciphers were used as early as in ancient times. They were one of the first ways (after steganography) to secure messages.

Simple substitution ciphers work by replacing each plaintext character by another one character. To decode ciphertext letters, one should use a reverse substitution and change the letters back.

To use this simple cipher, one should choose substitutions that will be used for changing all alphabet letters. This can be performed by writing all alphabet letters in the alphabetical order in the first row, and then in the second row the same letters but in any other random order. Letters from upper and lower rows form pairs that should be used during encryption.

For example, let us consider the following two sequences of letters which define the substitution cipher:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
TIMEODANSFRBCGHJKLPQUVWXYZ
One can notice that the letter F is encoded using the letter D, while the same ciphertext letter F corresponds to the plaintext litter J. On the other hand, the letter Z corresponds to Z (it is not changed during encryption).

Mixing of the alphabet can be proceed by determining a keyword (or a few keywords), writing it down (skipping repeated letters) under the original alphabet letters and completing remaining empty spaces at the end with the remaining alphabet letters. It makes it easier to remember the substitutions and to exchange the secret key between all sides.

This method has been used to create the substitution in the example above. A Greek sentence timeo Danaos et dona ferentes was used as its keywords.

One of the characteristics of simple substitution ciphers is that different plaintext alphabet letters would always produce different ciphertext letters. It is not possible that both of them would be encrypted by the same alphabet letter.

## Security of simple substitution ciphers

Because of the fact that every character can be encoded by every alphabet letter, there are 26! possible pairs of letters in the Latin alphabet (which is 26-letter long). This results in a large number of combinations. The provided security is approximately equal to the strength of the cipher with the secret key of size of 88 bits.

However, a much more effective approach than brute-force attacks is to use frequency analysis of ciphertext letters in order to break a simple substitution cipher. The letters in all languages appear in average texts with different frequencies. Thus, it is much faster to discover the substitutions used in the cipher, by comparing frequent ciphertext letters with the letters which are frequently used in the language used for encryption. By using this approach, it is assumed that analysing of encoded messages of size of about 50 letters, is sufficient for discovering the substitutions.