In the section on Caesar ciphers, we saw that there are only 26 possible ways of encrypting a message in English when using a Caesar cipher. A Caesar cipher is actually a special kind of substituion cipher and, if we turn our attention to all possible substitution ciphers based on a single alphabet (i.e. not just those created using a Caesar cipher), we will see that there are a lot more than 26 possible ways of encrypting a message.
Surprisingly, though, the more general substitution cipher is not much more difficult to crack than a Caesar cipher, as we shall see.
A substitution cipher takes the normal alphabet and swaps or substitutes each letter for another letter from the alphabet. This is what the Caesar cipher does, but the Caesar cipher does so with an additional rule: each letter is replaced by the letter that is a certain number of places away from it in the alphabet. So, if 'A' is to be replaced by 'C', then 'B' must be replaced by 'D', 'C' by 'E' and so on.
With a more general substitution cipher, the substitution letter can be chosen at random for each letter. If, therefore, we replace all 'A's with 'G's, then
we could replace all 'B's with any of the remaining letters (the whole alphabet, including 'B', but not 'G' as we have already used that for 'A'). Let us say
that we replace 'B' with 'R', we can now replace 'C' with any letter except the two we have already chosen ('G' and 'R'). And so on, until we have replaced all
26 letters. This is one possible example of what we might end up with:
The process for working out the number of possible substitution ciphers is as follows:
The total number of possibilities, therefore, is 26 x 25 x 24 x ... ... x 3 x 2 x 1.
This is referred to as 26 factorial and mathematicians write it as 26!.
This is a ridiculously large number, and the substitution cipher obviously offers many more possibilities than a Caesar cipher, and yet it is not much more difficult to crack ...