Science Software: Statistics, Probability, Odds, Combinatorial Mathematics, Algorithms.

Enigma Permutations, Encryption Decryption Keys, Code, Software

By Ion Saliu, Enigmatically At-Large

The Enigma machine was betrayed by humans and the dreadful Heil!

If we take 10 digits and 26 letters, Permutations of 36 elements is a monstrous number: 3 followed by 41 digits! You can try to generate such permutations either starting with the keyboard configuration; or indexing the elements starting at digit 0, to digit 9, then to A and all the way to Z. Looking at my keyboard, I can see 10 digits from 0 to 9 and 26 letters from A to Z: 36 elements in total. Permutations (36) = 3.71993326789901E+41.

We can ignore the digits, as the numbers can be expressed as words. In that case, Permutations (26) = 4.03291461126606E+26. If only 40%, even just 1%, … even only 0.00001% … of the permutations are totally different from permutation #1 (based on the keyboard layout), 40% of the number above is still an impossible numb...er for humans to deal with! The Germans made sure that A was not A, B was not B, C was not C… etc. … in any code. Just one letter as in the original setting could help with decoding.

Thus, one important condition is: NO letter encrypts to itself. The first alphabetical permutation is, for example:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Permutation #2 in the set is:

A B C D E F G H I J K L M N O P Q R S T U V W X Z Y
It cannot be an encryption key: Too many letters encrypt to themselves. The permutation must be discarded, as it does NOT encrypt any message.

Enigma was a very ingenious machine, a computer, really. It had a weakness, however. It relied on humans to begin with. Lots of messages started with the same word, or ended with the dreadful HEIL (as in "Heil Hitler")!

The creators of Enigma were smart enough to make sure that no configuration repeated digits or letters in the very same position as permutations #1 (1 2 3 4 5 ... 31 32 33 34 35 36). Then, the new configuration must have been totally different from the previous one. That is, absolutely no digit or letter repeated in the same position as previously. At least, they tried.

The Germans did not generate all possible permutations of 36 elements. They didn't have computers. Even the supercomputers of today have a very hard time with such a task. The Germans could have taken dice and print on each one a letter of the German alphabet. Put all dice in a drawing chamber, much like a lottery machine now. Draw one die at a time and place it in order drawn. If the die position coincided with its original rank in the alphabet, move it a few positions to the right. They could have generated thousands of unique encryption keys in a short time. See my software below.

Axiomatic one, I took an easier example: Just 6 elements (digits, or the numbers 1 to 6).

Permutations (6) = 720
Permutations of 6 digits that do NOT repeat digits in the same position compared to permutation #1: 287 (give or take a few), or approximately 40%. For 9 elements (e.g. digits) as in Sudoku, some 38% of the permutations do not repeat the elements in the same position (133497 out of 362880 total permutations or factorial of 9).

Let's say, we select first one permutation totally different from permutation # 1 (1 2 3 4 5 6); e.g. 5 4 6 2 1 3. Next time, the coders would select another permutation, but one that did not repeat any digits in the same position compared to the previous one; e.g. 2 3 5 1 6 4. And so on... Even if the Enigma creators could not generate all possible permutations of 36 elements, they had plenty of choices made randomly (easily from trillions of permutations).

The software that generates all types of sets, including permutations, is named Permute Combine. Special code can be added to generate only permutations totally different from permutation #1; and then select permutation after permutation totally different from previous ones.

 1  2  3  4  5  6
 1  2  3  4  6  5 - do NOT select as encryption key: has too many elements in the SAME position 
 1  2  3  5  4  6 - do NOT select as encryption key: has too many elements in the SAME position 
....
 2  1  4  3  5  6 - do NOT select as encryption key: has too many elements in the SAME position
 2  1  4  3  6  5 * acceptable encryption key: no element is in the same position
....
 3  4  1  5  6  2 * acceptable encryption key: no element is in the same position
 3  4  1  6  2  5 ** excellent encryption key: each element is more than one position
                     far from the original sequence 1 2 3 4 5 6
....
 3  4  2  1  6  5 * acceptable encryption key: no element is in the same position
....
 3  5  1  6  2  4 ** excellent encryption key: each element is more than one position
                     far from the original sequence
....
 4  5  1  6  2  3 ** excellent encryption key: each element is more than one position
                     far from the original sequence
....
 5  4  1  6  2  3 ** excellent encryption key: each element is more than one position
                     far from the original sequence
....
 6  4  5  1  3  2 ** excellent encryption key: each element is more than one position
                     far from the original sequence
....
 6  5  4  3  2  1 - NOT a good encryption key: it is a complete reverse
                    of the original sequence 1 2 3 4 5 6. 

Thousands of computer programmers all over the world can create such programs. I wrote a quick one. I generated permutations for 9 digits so that no digit came in the same position as in the original sequence (1 2 3 4 5 6 7 8 9, or A B C D E F G H I). Selecting one ** excellent encryption key and changing it every day would cover at least 100 years.

How about 256 characters in the Latin Extended Additional UNICODE? Selecting one ** excellent encryption key and changing it every day would cover probably hundreds of thousands of years. There are also Greek characters, Russian characters, Chinese, Arabic, Japanese, Sanskrit, etc. Put them together in a file and run a modified PermuteCombine. Selecting one ** excellent encryption key and changing it every day would last probably millions of years.

The headquarters would send to the field operators a simple, non-encrypted command: 13447892. That would represent the permutation rank 13,447,892 on the list of ** excellent encryption keys. At the end of the day, that permutation number (index, rank) would be crossed off. The headquarters would issue a new, unique permutation rank for the next 24 hours.

Of course, combinatorial software would have one function to encrypt based on a key and one function to decrypt based on the given key. The whole program won't be larger than one megabyte! The simple program I wrote to "cover" the examples above is just 35 KB in executable size.

Permute Combine has this function: Generate Words - Randomly. A word can be a single letter. I modified the code to make sure no letter in the permutation string falls in the same position as its alphabetical rank. The duplicates are stripped, and the entire file is sorted in ascending order. Look at the following screenshot, program name EnigmaPermutations:

Free software program to generate randomized permutations as encryption keys.

I created an input file with the 26 letters of the English alphabet (capitals only, Characters.txt):
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

I generated 10,000 permutations of 26 letters each. I uploaded the output file to the freeware section of my website. As you can see, no letter falls in the same position as in the input file (the order of the English alphabet): there is no A in the 1st position, no B in the 2nd position, no C in the 3rd position ... no Z in the last position. The encryption is even better starting with letter C, and no A in 2nd, no B in 3rd. The CIA might like this encryption key:
C I A J G E R U O W B P N X D F L M Y S Z T H Q V K

The Enigma machine complicated matters by orders of magnitude by using rotors. For the sake of exemplification, a rotor is like a 26-letter key. One character is encrypted with the first 26-letter string (key); the 2nd character is encrypted with the second 26-letter key; the 3rd character is encrypted with the third 26-letter key; etc. Highly trained personnel can quickly and accurately encrypt/decrypt applying even 5 or 13 strings (cypher keys). All work can be done manually with pencil and paper. (The real computer hadn't been invented!)

Z X P K C R T E G L N B J I W H S Y M A Q O U F V D
B C Z J M Q D O A K L R F T U W Y E X G N I P S H V
H J W P B K O Y L G T I V C A Z M X U D S F E R N Q

EBZHHBIZXVWDGUCZSLWFHAAWWTB (IT AIN'T THAT EASY — EVER! See a practical example of encrypting and decrypting a longer message on the 3 encryption keys above.)

There are plenty of keys to use... for hundreds of years! The maintenance is much easier and cheaper — and more secure — than using a machine. Print the 5-"rotor" keys (strings) on one page of a notepad. Even print the exact date on each page. One page could have 3 encryption/decryption keys, another day 4 keys, another day 5 cypher keys. Having a random amount of keys for each day would make decoding much more difficult! The encryption page is valid for one day. Destroy the page at the end of the day. Issue a new encryption notepad every month. In case the unit falls to the enemy: It is very easy to destroy a notepad and the duplicate!

The Enigma machine was harder to maintain. It had voluminous manuals. Worst, the Enigma messages had revealing clues, like the dreadful Heil Hitler. The encryption notepad does not require any clue; just the date will do.

As fast as today's computers are, deciphering the code of one day would take a very long time, probably many years. The computers still need humans to check if groups of letters make any sense in the presumed language of the coding.

Better forget about it — it is FUTILE, Bletchley Park! Even my easiest and simplest form of encryption is UNBREAKABLE for all intents and purposes. It can be also used over the phone or radio by spelling the letters. Methinks there are other methods of encryption much more complicated than mine, therefore much harder to break…

Enigma, Venoma prove that there is no encryption cipher code without eventual decryption.

Resources in Theory of Probability, Mathematics, Statistics, Combinatorics, Software

See a comprehensive directory of the pages and materials on the subject of theory of probability, mathematics, statistics, combinatorics, plus software.

Computers create fast code breakers by generating gigantic amounts of permutations as in Enigma.

See Enigma encryption, code via huge amounts of possibilities or permutation combinations.


| Home | Search | New Writings | Odds, Generator | Contents | Forums | Sitemap |

Enigma code was based on a number of permutations consisting of 41 digits.