How were codes in WW1 reciphered (to enhance security levels) without them turning meaningless? In WW1, the Germans made their communications secret by encoding their messages. This meant that the message's sender would have a codebook with all possible words and phrases he might use listed in alphabetical order. Those were attached to a random number. He would then write down the numbers corresponding to his message. The receiver would have the same book, just reversed. He would have all numbers listed from the smallest to the biggest, and he would be able to decode the message by finding the corresponding word/phrase for each number.
So far, so good. Now, I keep reading about how Germans would add a layer of enciphering to enhance security. I just do not get how this wouldn't be paradoxical with the concept of the codebook. I have two different outcome suggestions, and they both fall short:

Suppose the sender wanted to send the word &quot;hi.&quot; He would then encipher this and get, let's say, &quot;xt.&quot; He would then look at his codebook and find no number corresponding to &quot;xt.&quot;

Suppose the sender wanted to send the word &quot;hi.&quot; He would then find the corresponding number for &quot;hi.&quot; He would then decipher that number and get a different number. The receiver would then look up the number and find either a non-existing number or a wrong word.
Here are two examples in the literature of the history of cryptography that state how an extra layer was added:


Page 66 in The History of Code Breaking:
&quot;The Zimmermann Telegram was superenciphered (encoded again by using the German Diplomatic Code Book, Code No. 13040).&quot;
Under &quot;VB codebook&quot; in the Wiki page about Room 40:
&quot;Re-ciphering of the code was accomplished using a key made up of a codeword transmitted as part of the message and its date written in German. These were written down in order and then the letters in this key were each numbered according to their order of appearance in the alphabet. This now produced a set of numbered columns in an apparently random order. The coded message would be written out below these boxes starting top left and continuing down the page once a row was filled. The final message was produced by taking the column numbered '1' and reading off its contents downward, then adding on the second column's digits, and so on.&quot;
The concept is called superencipherment or multiple encryption, and works as follows:


The original message M is enciphered using the code book, resulting in an enciphered message C1.
C1 is then treated as the plaintext, and enciphered using another method, resulting in a new ciphertext C2.
C2 is then sent to the receiver
The receiver uses the decryption algorithm for the second method on C2, obtaining C1.
The receiver then uses the code book to decrypt C1 and get the message M.


Creating an example:
Suppose I want to send the message "Small supplies of fruit expected. Buy as much as you can."
For my code book, I will use the A B C Universal Commercial Electric Telegraphic Code, 4th Edition.

Step 1: On page 128, we have the phrase "Small supplies of fruit expected.", with the corresponding code number 06375.  Moving to page 45, we find "Buy as much as you can." with the code number 02221. So in this example, C1 is "06375 02221".

Step 2: For the second level of encryption, I will add 13348 to each code number (ignoring any carry or borrow beyond 5 digits).  So to encrypt C1, we calculate 06375+13348=19723 and 02221+13348=15569, resulting in C2 as "19723 15569".

Step 3: The message C2 ("19723 15569") is sent to the receiver.

Step 4: The receiver decrypts C2 by subtracting 13348 from each code number.  So the receiver would calculate 19723-13348=06375 and 15569-13348=02221. This results in the message C1 equal to "06375 02221".

Step 5: The receiver then uses the code book to decrypt "06375 02221". Since I am using a one-part code here, again go to pages 128 and 45 to get the original message "Small supplies of fruit expected. Buy as much as you can."

As long as you maintain the sequence "Encrypt using A, Encrypt using B, send, Decrypt using B, Decrypt using A", the exact encryption steps can be replaced as long as the sender and receiver agree on the algorithms and keys.