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

Enigma Permutations, Encryption Decryption Keys, Code, Software

By Ion Saliu, Enigmatically At-Large

The unbreakable code of Enigma machines was broken due to human error, complacency, and mechanics.

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. One and only one letter was not "encrypted"! Throw that key away!

If just one letter encrypted to itself, look how easier it would be to decipher. You only need a team of 26 experts. Expert A would deal with the scenario A encrypts to A. Expert B would deal with the scenario B encrypts to B... Expert Z would deal with the scenario Z encrypts to Z. It is somehow easier to discover patterns.

If two letters had encrypted to themselves, it would have been even easier to decipher... significantly easier. You only need a team of 26 ^ 25 = 650 experts. Expert 1 would deal with the scenario A encrypts to A; B encrypts to B. Expert 2 would deal with the scenario A encrypts to A, C encrypts to C... Expert 650 would deal with the scenario Y encrypts to Y, Z encrypts to Z. Axiomatics, it would be far easier to discover patterns!

If three or more letters had encrypted to themselves, encryption would have been NO MORE! And, what happens if the restriction "No letter encrypts to itself" is enforced? Well then, any number of keys could encrypt to themselves! Quite certainly, encryption would no longer be possible!

You might see nowadays guys on YouTube claiming that the setting "No letter encrypts to itself" was a real weakness of the Enigma machines! NO, young cuckoos! The non-self-encryption was a real strength of Enigma! You'll see below real weaknesses of the machine.

Enigma was a very ingenious machine, a computer, really. It had weaknesses, 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")! Most importantly, the machine had only 5 physical "encryptors" (i.e., rotors). The decrypting operatives already possessed the 5 rotors, along with the machine. And then, only arrangements of 3 from 5 rotors were inside the machine.

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 (or just the 26 letters). 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 the easiest example: Just 6 elements (digits, or the numbers 1 to 6).

Permutations (6) = 720 total
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 is completely different. 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 26 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 away from the first 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 away from the first key

4 5 1 6 2 3 ** excellent encryption key: each element is more than one position away from the original sequence

5 4 1 6 2 3 ** excellent encryption key: each element is more than one position away from the first sequence

6 4 5 1 3 2 ** excellent encryption key: each element is more than one position away from the original sequence

6 5 4 3 2 1 - NOT a good encryption key: it is a complete reverse of the original key 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 (26th). 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 number 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 — they were able to burn tons of paper documents in hours!

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.

The worst drawback: an Enigma machine could be seized by the enemy... and several Enigmas were, indeed, captured by the Western Allies, and the Polish intelligence services even before World War II. Possessing a machine meant possessing the rotors as well, and the plugboards, and the 3 of 5 rotor arrangements schedules.

Arrangements of 5 taken 3 at a time is 5 * 4 * 3 = 60 possibilities.

But when you have 10000 "rotors" (i.e., encryption keys as you can see here), total arrangements of 3 from 10000 equals 10000 * 9999 * 9998 = over 999.7 billion possibilities. And that's not all! The encryptors could employ any number of keys or, say, virtual rotors... 4, 5, 6, ..., 13, ..., etc. Gazillions of arrangements would be possible in seconds — adding billions of years to the decryption effort!

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… But I don't think so — nothing is harder than the Impossible!

A few kokostirks/shkiottorbahns issued a challenge to yours truly. I upped the ante. I emailed them a 100-or-so-character message encrypted as per above. The encryption keys are from that 10,000-line file available to everybody. However, I did not specify how many keys I used (I could have revealed that number without problems, though). The successful deciphering dude should be able to download all my software and also shut down my website for good!

I ain't afraid at all! I am a whole lot more scared of lightning, or being mulled by a lion or tiger in the street... or even being made history by COVID-19, the farce I first believed in at the beginning, in the year of grace 2020...

And that's the reason I do not publish the full-purpose software to automatically encrypt and decrypt messages as presented on this page. Hopefully, I don't think a calamity as World War II strikes humanity again...

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.

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

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

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