The Enigma Project
In May 2018 we visited the The Government Code and Cypher School at Bletchley Park in the UK. It left a lasting impression on us: How the work done there by the British, and the earlier work by the Polish, was instrumental in bringing about an early end to World War II, saving countless lives. Central to their effort was decoding messages from the infamous German Enigma machine.
Bletchley Park Mansion and the Enigma Machine
We always wanted to commemorate this experience by writing something about it for school students here. However, we are not historians and there are already so many on-line resources, including some very good Enigma machine software simulators, so we wondered how we could contribute in some other way? In the end we decided to start a project of our own: To build a working Enigma machine toy for kids.
We started by researching how the Enigma machine worked. Our first effort was to build a software simulator of the Enigma machine, written in Python 3. However, this was just a proof of concept, to show that we had correctly understood the design of the real Enigma machine. After testing this program against authentic, historical, messages, from different models of the machine, we progressed to the next stage of building a battery-operated, toy Enigma machine.
Enigma machine software simulator
Our python 3 Enigma Machine simulator program, is here and the output is here. Please note that this program is still under development and testing. So far it has been verified to work correctly on 9/11, 3-rotor messages and 3/3, 4-rotor messages. We note that authentic, historical messages, complete with the full Enigma machine settings and decrypted message keys are somewhat hard to come by... There is a scene in the movie "The imitation game" where the BP team are ordered to "burn everything". So, maybe that's why? We don't know.
References
How it works
Here is brief recap of how the Enigma machine works. See the above references for more details:
- When one of 26 letter keys (A-Z) is pressed on the keyboard, it is scrambled progressively by:
- The plugboard wiring;
- 3 or 4 rotors, each with specific wiring, in the forward, or right-to-left, direction;
- the static reflector wiring;
- the same 3 or 4 rotors, but in the reverse, or left-to-right, direction;
- and finally, the plugboard wiring again.
- Each stage is a simple substitution cipher: The rotors have 26 substitutions, the plugboard has 13 pairs of substitutions
- The message is further scrambled using the following methods:
- Inserting cables into the plugboard (usually 10 out of a possible 13). Each cable creates a symmetrical substitution of keys and lamps.
- Setting the rotor starting positions
- Offsetting the rotor positions with a ring
- When a button is pressed, but before any output is displayed:
- If any rotor is at one or two predetermined notch positions on its ring, the rotor to its left is advanced one step
- The right hand rotor is unconditionally advanced one step
- The output is then illuminated on one of 26 letter lamps (A-Z)
- The output changes each time a key is pressed, even if it is the same key. However, the output cannot be the same as the keyed letter
- There is no space. Uncommon letters, like X, may be used instead.
- The enigma machine can be used symmetrically, for either encryption or decryption, with exactly the same starting settings
Sample Output
Enigma Machine Simulator. Version 1.4
Copyright (c) 2020, Julie VK3FOWL and Joe VK3YSP
For the School Amateur Radio Club Network https://www.sarcnet.org/
This is free software released into the public domain under the GNU General Public License
Configuration:
Rotor Name: I
Rotor Forward Wiring: EKMFLGDQVZNTOWYHXUSPAIBRCJ
Rotor Reverse Wiring: UWYGADFPVZBECKMTHXSLRINQOJ
Rotor Notch Positions: Q
Rotor Name: II
Rotor Forward Wiring: AJDKSIRUXBLHWTMCQGZNPYFVOE
Rotor Reverse Wiring: AJPCZWRLFBDKOTYUQGENHXMIVS
Rotor Notch Positions: E
Rotor Name: III
Rotor Forward Wiring: BDFHJLCPRTXVZNYEIWGAKMUSQO
Rotor Reverse Wiring: TAGBPCSDQEUFVNZHYIXJWLRKOM
Rotor Notch Positions: V
Rotor Name: IV
Rotor Forward Wiring: ESOVPZJAYQUIRHXLNFTGKDCMWB
Rotor Reverse Wiring: HZWVARTNLGUPXQCEJMBSKDYOIF
Rotor Notch Positions: J
Rotor Name: V
Rotor Forward Wiring: VZBRGITYUPSDNHLXAWMJQOFECK
Rotor Reverse Wiring: QCYLXWENFTZOSMVJUDKGIARPHB
Rotor Notch Positions: Z
Rotor Name: VI
Rotor Forward Wiring: JPGVOUMFYQBENHZRDKASXLICTW
Rotor Reverse Wiring: SKXQLHCNWARVGMEBJPTYFDZUIO
Rotor Notch Positions: ZM
Rotor Name: VII
Rotor Forward Wiring: NZJHGRCXMYSWBOUFAIVLPEKQDT
Rotor Reverse Wiring: QMGYVPEDRCWTIANUXFKZOSLHJB
Rotor Notch Positions: ZM
Rotor Name: VIII
Rotor Forward Wiring: FKQHTLXOCBJSPDZRAMEWNIUYGV
Rotor Reverse Wiring: QJINSAYDVKBFRUHMCPLEWZTGXO
Rotor Notch Positions: ZM
Rotor Name: BETA
Rotor Forward Wiring: LEYJVCNIXWPBQMDRTAKZGFUHOS
Rotor Reverse Wiring: RLFOBVUXHDSANGYKMPZQWEJICT
Rotor Notch Positions: ZM
Rotor Name: GAMMA
Rotor Forward Wiring: FSOKANUERHMBTIYCWLQPZXVGJD
Rotor Reverse Wiring: ELPZHAXJNYDRKFCTSIBMGWQVOU
Rotor Notch Positions: ZM
Reflector Name: A
Reflector Wiring: EJMZALYXVBWFCRQUONTSPIKHGD
Reflector Name: B
Reflector Wiring: YRUHQSLDPXNGOKMIEBFZCWVJAT
Reflector Name: C
Reflector Wiring: FVPJIAOYEDRZXWGCTKUQSBNMHL
Reflector Name: B THIN
Reflector Wiring: ENKQAUYWJICOPBLMDXZVFTHRGS
Reflector Name: C THIN
Reflector Wiring: RDOBJNTKVEHMLFCWZAXGYIPSUQ
Message: Operation Barbarossa, 1941 Pt 1
Rotor order: ['II', 'IV', 'V']
Ring positions: [2, 21, 12]
Message key: BLA
Reflector: B
Plug pairs: AV BS CG DL FU HZ IN KM OW RX
Plaintext: AUFKL XABTE ILUNG XVONX KURTI
NOWAX KURTI NOWAX NORDW ESTLX
SEBEZ XSEBE ZXUAF FLIEG ERSTR
ASZER IQTUN GXDUB ROWKI XDUBR
OWKIX OPOTS CHKAX OPOTS CHKAX
UMXEI NSAQT DREIN ULLXU HRANG
ETRET ENXAN GRIFF XINFX RGTX
Ciphertext: EDPUD NRGYS ZRCXN UYTPO MRMBO
FKTBZ REZKM LXLVE FGUEY SIOZV
EQMIK UBPMM YLKLT TDEIS MDICA
GYKUA CTCDO MOHWX MUUIA UBSTS
LRNBZ SZWNR FXWFY SSXJZ VIJHI
DISHP RKLKA YUPAD TXQSP INQMA
TLPIF SVKDA SCTAC DPBOP VHJK
Encoding: VERIFIED
Decoding: VERIFIED
Message: Operation Barbarossa, 1941 Pt 2
Rotor order: ['II', 'IV', 'V']
Ring positions: [2, 21, 12]
Message key: LSD
Reflector: B
Plug pairs: AV BS CG DL FU HZ IN KM OW RX
Plaintext: DREIG EHTLA NGSAM ABERS IQERV
ORWAE RTSXE INSSI EBENN ULLSE
QSXUH RXROE MXEIN SXINF RGTXD
REIXA UFFLI EGERS TRASZ EMITA
NFANG XEINS SEQSX KMXKM XOSTW
XKAME NECXK
Ciphertext: SFBWD NJUSE GQOBH KRTAR EEZMW
KPPRB XOHDR OEQGB BGTQV PGVKB
VVGBI MHUSZ YDAJQ IROAX SSSNR
EHYGG RPISE ZBOVM QIEMM ZCYSG
QDGRE RVBIL EKXYQ IRGIR QNRDN
VRXCY YTNJR
Encoding: VERIFIED
Decoding: VERIFIED
Message: Scharnhorst (Konteradmiral Erich Bey), 1943
Rotor order: ['III', 'VI', 'VIII']
Ring positions: [1, 8, 13]
Message key: UZV
Reflector: B
Plug pairs: AN EZ HK IJ LR MQ OT PV SW UX
Plaintext: YKAEN ZAPMS CHZBF OCUVM RMDPY
COFHA DZIZM EFXTH FLOLP ZLFGG
BOTGO XGRET DWTJI QHLMX VJWKZ
UASTR
Ciphertext: STEUE REJTA NAFJO RDJAN STAND
ORTQU AAACC CVIER NEUNN EUNZW
OFAHR TZWON ULSMX XSCHA RNHOR
STHCO
Encoding: NOT VERIFIED
Decoding: NOT VERIFIED
Message: Enigma Instruction Manual, 1930
Rotor order: ['II', 'I', 'III']
Ring positions: [24, 13, 22]
Message key: ABL
Reflector: A
Plug pairs: AM FI NV PS TU WZ
Plaintext: FEIND LIQEI NFANT ERIEK OLONN
EBEOB AQTET XANFA NGSUE DAUSG
ANGBA ERWAL DEXEN DEDRE IKMOS
TWAER TSNEU STADT
Ciphertext: GCDSE AHUGW TQGRK VLFGX UCALX
VYMIG MMNMF DXTGN VHVRM MEVOU
YFZSL RHDRR XFJWC FHUHM UNZEF
RDISI KBGPM YVXUZ
Encoding: VERIFIED
Decoding: VERIFIED
Message: 215 AAA FRA ABIRUXKP
Rotor order: ['II', 'I', 'V']
Ring positions: AAA
Message key: FRA
Reflector: B
Plug pairs: AB IR UX KP
Plaintext: ANBUL MEGRA ZGOES TINGS TRENG
GEHEI MEMEL DUNG
Ciphertext: PCDAO NONEB CJBOG LYMEE YGSHR
YUBUJ HMJOQ ZLEX
Encoding: VERIFIED
Decoding: VERIFIED
Message: PAGE_40_AFDFX (Norrköping Enigma message)
Rotor order: ['V', 'I', 'IV']
Ring positions: KSH
Message key: SIN
Reflector: B
Plug pairs: BF DV EJ GM IY KP LZ NX OQ TW
Plaintext: WAETI GKEIT SBERI QTVOM XSEQS
XDREI XVIER NULLX SEITE XZWOX
LFLXK DOXEI NSXXP REIXS TRIQX
NULLX LFLXK DOXEI NS
Ciphertext: DSBDB DCOSG CYAMD SITWW ZUSDL
JBXAP VJMXL DKPUU IAPYY USNRJ
OHKGO WRCDK BNYZE LVKWY MWOPN
TVOSN FNOCF NUDSQ PU
Encoding: VERIFIED
Decoding: VERIFIED
Message: PAGE_40_AYDJM (Norrköping Enigma message)
Rotor order: ['V', 'I', 'IV']
Ring positions: KSH
Message key: OEL
Reflector: B
Plug pairs: BF DV EJ GM IY KP LZ NX OQ TW
Plaintext: TAETI GKEIT SBERI QTVOM XSEQS
XDREI XVIER NULLX SONDE RANLA
GEXZW OXSXI TEXZW OXLGX KDOXR
OEMDR EIXXN ULLXS TRIQX NULLX
SEITE XDREI XLGXK DOXRO EMXDR
EIXNU LLXST RIQXZ WOXLG XKDOX
ROEMX DREI
Ciphertext: YMZAX OZBCW GZFIG IMWXQ WGAKO
HLICK JOHFJ FVNAV AUHAW SXEIL
ABDJU BEUAQ SAMWJ WGUPO JZNLB
CDDAV BXBQO PTYRN ZTPUP ABQBO
JDJOX RJKMG LYJLQ PBAQX AIAVX
OGQHK TTOPH ZROKU MSSJL ONINR
GUBQF AJPP
Encoding: VERIFIED
Decoding: VERIFIED
Message: PAGE_40_PYCMW (Norrköping Enigma message)
Rotor order: ['I', 'III', 'V']
Ring positions: XLG
Message key: GRB
Reflector: B
Plug pairs: AK BZ CE DX GL JQ MU NV OT SY
Plaintext: TAETI GSKEI TSBER IQTFU ERDEN
SEQSX DREIX VIERN ULLXS ONDER
ANLAG EZWOX SEITE NZAHL ZWOXL
GTKDO XROEM ZWOXN EUNMO MMAFU
ENFXL GXKDO XROEM ZWOX
Ciphertext: PYZXK LLQFH ELFTJ AWURW BYZOW
LFHFM NFYMW EGDEC HKKGX HLTRQ
OEKIB FKLHH QWXLI QVMDV YTSZH
XUSJX DACDT BBWUJ IFEGI YZZJX
IYHLV WNRVE VQKMG WNMH
Encoding: NOT VERIFIED
Decoding: NOT VERIFIED
Message: PAGE_40_ZBAQW (Norrköping Enigma message)
Rotor order: ['I', 'III', 'V']
Ring positions: XLG
Message key: HJO
Reflector: B
Plug pairs: AK BZ CE DX GL JQ MU NV OT SY
Plaintext: TAETI GKEIT SBIRI CHTVO MXSEQ
SXORE IXVIE RNULL XAQTX AUFGE
NOMME NXNUL LXMEF OERDE RTXLE
ITSTE LLEWA RXKRA KAUXL XGXKD
OXROE MXAQT X
Ciphertext: OWTSB STOLY MVABU FAAUW ECRQY
ISIGZ DZMCH ECVVZ GIZOY UJIDT
FZUUO URDWV IMYOL XIOGN MKCYQ
QEYYT WITHH BYXAW AYXRT BUOOX
XPNET ERPZB I
Encoding: VERIFIED
Decoding: VERIFIED
Message: PAGE_47_RTQSX (Norrköping Enigma message)
Rotor order: ['IV', 'I', 'V']
Ring positions: PVG
Message key: KJO
Reflector: B
Plug pairs: AG BS CW EN FZ HJ IO KT LX PR
Plaintext: KOMMA HIERZ UWIRD DERVE RKGHR
DERGE GENFU NKSTE LVEBE OBAQT
ETUND BXIAB GABEE IFESF UERDI
EABST MMEND EFUMK STELL ENIQT
WIQTV GENFU KKSPR UQESU SWPUN
KTDER EMPFA ENGER AUFSQ WNBUN
GSLUE CKEX
Ciphertext: WNLWS YZUKN CQSHO QCLAZ LRJXD
RIFLD WNMOQ IBQZG JGIHR PTIWP
HYAUC EIJMM YXPTO NGQOX DAUKY
IVNQA OYVFC XKJNO JQVPU MUZHF
RMGGJ IUILK UIESJ KOOJN IYNBD
VBOXM UAKRE MODLB XHYGT XLUNF
NHWYW QGVO
Encoding: VERIFIED
Decoding: VERIFIED
Message: PAGE_47_KRNV (Swedish Enigma M3 intercept)
Rotor order: ['VII', 'IV', 'VI']
Ring positions: AGW
Message key: RTA
Reflector: B
Plug pairs: BM DX EW GP JO KV NZ RT
Plaintext: SEENA CHRIC HTLEU CHTSC HIFFE
MILSX BQPLA NNORD FUENF NUOME
RDREI EINSL IEGTW IEDER AUFST
ATION
Ciphertext: IWNOX NFTRJ NPMRA WPZNK QECKK
TWIOB EXLBH FLHHJ LMYCZ GCYSL
CUDIJ DLGQQ PRYUR GKGTF KRQEP
IOVBI
Encoding: VERIFIED
Decoding: VERIFIED
Message: M4 Schroeder Message
Rotor order: ['BETA', 'II', 'IV', 'I']
Ring positions: AANV
Message key: MCSF
Reflector: B THIN
Plug pairs: AT CL DH EP FG IO JN KQ MU RX
Plaintext: VVVJS CHREE DERJA UFGEL EITKU
RSFUE NFFUE NFGRA DNICH TSGEF
UNDEN YMARS CAIER EBEFO HLENE
SQUAD RATXS TANRO RTMAR QUANT
ONJOT ADREI NEUNN EUNFU ENFXS
SSOOO VIERY SEEDR EMYEI NSNUL
YYEIN SNULB EDECK TYZWO ACHTM
BSTEI GTYNB BELSI CHTEI NSSMT
Ciphertext: TMKFN WZXFF IIYXU TIHWM DHXIF
ZEQVK DVMQS WBQND YOZFT IWMJH
XHYRP ACZUG RREMV PANWX GTKTH
NRLVH KZPGM NMVSE CVCKH OINPL
HHPVP XKMBH OKCCP DPEVX VVHOZ
ZQBIY IEOUS EZNHJ KWHYD AGTXD
JDJKJ PKCSD SUZTQ CXJDV LPAMG
QKKSH PHVKS VPCBU WZFIZ PFUUP
Encoding: VERIFIED
Decoding: VERIFIED
Message: M4 Looks Message
Rotor order: ['BETA', 'II', 'IV', 'I']
Ring positions: AAAV
Message key: VJNA
Reflector: B THIN
Plug pairs: AT BL DF GJ HM NW OP QY RZ VX
Plaintext: VONVO NJLOO KSJHF FTTTE INSEI
NSDRE IZWOY YQNNS NEUNI NHALT
XXBEI ANGRI FFUNT ERWAS SERGE
DRUEC KTYWA BOSXL ETZTE RGEGN
ERSTA NDNUL ACHTD REINU LUHRM
ARQUA NTONJ OTANE UNACH TSEYH
SDREI YZWOZ WONUL GRADY ACHTS
MYSTO SSENA CHXEK NSVIE RMBFA
ELLTY NNNNN NOOOV IERYS ICHTE
INSNU LL
Ciphertext: NCZWV USXPN YMINH ZXMQX SFWXW
LKJAH SHNMC OCCAK UQPMK CSMHK
SEINJ USBLK IOSXC KUBHM LLXCS
JUSRR DVKOH ULXWC CBGVL IYXEO
AHXRH KKFVD REWEZ LXOBA FGYUJ
QUKGR TVUKA MEURB VEKSU HHVOY
HABCJ WMAKL FKLMY FVNRI ZRVVR
TKOFD ANJMO LBGFF LEOPR GTFLV
RHOWO PBEKV WMUQF MPWPA RMFHA
GKXII BG
Encoding: VERIFIED
Decoding: VERIFIED
Message: M4 SOLUTION OF THE LAST OF THE “HMS HURRICANE” INTERCEPTS
Rotor order: ['BETA', 'VI', 'I', 'III']
Ring positions: ZZTG
Message key: NBHL
Reflector: B THIN
Plug pairs: BQ CR DI EJ KW MT OS PX UZ GH
Plaintext: BOOTK LARXB EIJSC HNOOR BETWA
ZWOSI BENXN OVXSE CHSNU LCBMX
PROVI ANTBI SZWON ULXDE ZXBEN
OETIG EGLME SERYN OCHVI EFKLH
RXSTE HEMAR QUBRU NOBRU NFZWO
FUHFX LAGWW IEJKC HAEFE RJXNN
TWWWF UNFYE INSFU NFMBS TEIGE
NDYGU TESIW XDVVV JRASC H
Ciphertext: HCEYZ TCSOP UPPZD ICQRD LWXXF
ACTTJ MBRDV CJJMM ZRPYI KHZAW
GLYXW TMJPQ UEFSZ BOTVR LALZX
WVXTS LFFFA UDQFB WRRYA PSBOW
JMKLD UYUPF UQDOW VHAHC DWAUA
RSWTK OFVOY FPUFH VZFDG GPOOV
GRMBP XXZCA NKMON FHXPC KHJZB
UMXJW XKAUO DXZUC VCXPF T
Encoding: VERIFIED
Decoding: VERIFIED
>>>
Enigma machine toy
We decided to design and build a miniature, battery operated, toy Enigma machine for kids, with the following specifications:
- Authentic Enigma encryption and decryption
- Slim, hand-held device
- Battery operated
- On-Off switch
- Read-in-the-dark display for both settings and messages
- Non-volatile storage of settings
- Single press-button rotary-encoder type control
- Built-in Morse code beeper
We had a previous design of a similar Arduino product, which we called My1stMicro, that we used as a starting point. The device already had an Arduino microcontroller, an oLED display and a single press-button rotary-encoder type control on a small PCB. With a redesign for a suitable case and the addition of a beeper, it would do the job. Of course the Python 3 code we developed for the simulator above would have to be converted into C and a Morse code generator added. The design of an easy to use, Graphical User Interface for the tiny 0.6-inch oLED display would also be quite a challenge.
My1stMicro Printed Circuit Board