## Double Encryption

What is it?  Double Encryption is exactly what it sounds like. It is the process of encrypting a message multiple times using the same or a different algorithm. But some double encryptions are much more secure than others. To give you a general idea, let's look at some possibilities:

simple substitution + simple substitution = simple substitution (pointless)

Vigenere  + Vigenere = Vigenere --> the key length of the new Vigenere cipher is just equal to the least common multiple of the key lengths that were used in the successive Vigenere encryptions. This improves security, but it is also pointless. Why not just choose a longer key?

transposition + transposition = double transposition --> this is EXTREMELY difficult to decode if it is done well. Doing two successive horizontal transpositions is pointless, but doing a horizontal transposition followed by a vertical transposition is much more secure. A double vertical transposition is also highly secure.

transposition + substitution = a relatively secure cipher. But this can still be cracked because the frequencies will reveal that this is a substitution cipher, but when you try to solve it as a substitution cipher, nothing will work. Hence, it must have also been transposed. The challenge is figuring out which transposition algorithm was used.

transposition + Vigenere = another relatively secure cipher, more secure than a transposed simple substitution cipher. But again, frequencies can tell. It is much more challenging, however, to figure out which transposition algorithm was used because it is more difficult to "score" a Vigenere cipher based on how likely it is that it could represent English.

Vigenere + Caesar Shift = Vigenere --> just think of it as a Vigenere cipher + another Vigenere cipher with a key length of one. Therefore, the new Vigenere cipher must have a key length equal to the LCM of one and the old Vigenere cipher's key length, which is just equal to the old Vigenere cipher's key length. All that this does is it changes the key used for the Vigenere cipher.

Vigenere +  substitution = NEAR IMPOSSIBLE TO DECRYPT, assuming that the substitution alphabet and the Vigenere key are generated randomly. This can only be (feasibly) decrypted if the specific substitution mapping is known. Otherwise, if spaces are not preserved, the key for the Vigenere cipher is long, and the substitution alphabet is generated randomly, this double-encryption would be nearly as secure as a one-time pad (see Polyalphabetic Ciphers).

Recognizing it: double encryption is very difficult to recognize, but when it can be recognized, it will be either a transposition + substitution or a transposition + Vigenere (or some other polyalphabetic cipher). Double transposition cannot feasibly be recognized. If the frequencies of a message and its index of coincidence match up with those of either a substitution cipher or a Vigenere cipher, but it seems impossible to decode, then the message has most likely been double encrypted.

Breaking it: There is a clever way to decode a transposition + substitution cipher using the brute-force method. You brute-force through all the possible transposition algorithms, and for each untransposed message count the number of appearances of its most frequent trigram. It turns out that the right decryption will have a trigram count that is way higher than that of all the other possible decryptions because the word 'THE' appears so frequently in English. A transposition + Vigenere cipher is harder to decode, but not impossible. It relies on the same principle -- the right decryption will most likely have the highest trigram count simply due to the repetitive nature of the English language, though it will be considerably closer to the trigram counts of the other possible decryptions. Another way to decode this cipher is to run a probable key lengths calculator on every possible transposition and see which transposition results in a probable key length that has the highest corresponding index of coincidence. Compared to the trigram analysis, this probable-key-lengths method is generally more effective for Vigenere ciphers. You can try these methods yourself using Python programs provided in Tools. First, encrypt a transposed Vigenere cipher. Then, use each of the described algorithms to try and break it.

Takeaway:  Messages that have been double encrypted are complex, but they can be decrypted (most of the time). The two that are near impossible to recognize and crack using modern technology are double transposition and Vigenere + substitution. Of course, if it is known that a message has been double transposed, it becomes easier to decode the message. But when it comes to real codebreaking, you know nothing about what you want to crack.