Package: crypto-enigma
An Enigma machine simulator with state and encoding display for Python 2.7.Currently support is only provided for thosemachine modelsin most
widespread general use during the war years: theI,M3, andM4.Functionality: package APIThe package provides functionality for generating a machine configuration
from a conventional specification, examining the state of a configuration, simulating
the operation of a machine by stepping between states, and
encoding messages:Create a machine configuration (see thedocumentationforconfig_enigma_from_string):>>> from crypto_enigma import *
>>> cfg = EnigmaConfig.config_enigma_from_string(u'B-I-III-I EMO UX.MO.AY 13.04.11')Encode messages (see thedocumentationforenigma_encoding):>>> cfg.enigma_encoding(u'TESTINGXTESTINGUD')
u'OZQKPFLPYZRPYTFVU'

>>> cfg.enigma_encoding(u'OZQKPFLPYZRPYTFVU')
u'TESTINGXTESTINGUD'Show configuration details (see thedocumentationforconfig_string):>>> print(cfg.config_string(letter=u'X', format='internal', mark_func=lambda c: '(' + c + ')'))
X > ABCDEFGHIJKLMNOPQRSTUVW(X)YZ
  P YBCDEFGHIJKLONMPQRSTXVW(U)AZ         UX.MO.AY
  1 HCZMRVJPKSUDTQOLWEXN(Y)FAGIB  O  05  I
  2 KOMQEPVZNXRBDLJHFSUWYACT(G)I  M  10  III
  3 AXIQJZ(K)RMSUNTOLYDHVBWEGPFC  E  19  I
  R YRUHQSLDPX(N)GOKMIEBFZCWVJAT         B
  3 ATZQVYWRCEGOI(L)NXDHJMKSUBPF         I
  2 VLWMEQYPZOA(N)CIBFDKRXSGTJUH         III
  1 WZBLRVXAYGIPD(T)OHNEJMKFQSUC         I
  P YBCDEFGHIJKLONMPQRS(T)XVWUAZ         UX.MO.AY
T < CNAUJVQSLEMIKBZRGPHXDFY(T)WOSimulate machine operation (see thedocumentationforprint_operation):>>> cfg.print_operation(message=u'TESTING', show_step=True, mark_func=lambda c: '(' + c + ')')
0000       CNAUJVQSLEMIKBZRGPHXDFYTWO   EMO  19 10 05
0001  T > UNXKGVERLYDIQBTWMHZ(O)AFPCJS  EMP  19 10 06
0002  E > QTYJ(Z)XUPKDIMLSWHAVNBGROFCE  EMQ  19 10 07
0003  S > DMXAPTRWKYINBLUESG(Q)FOZHCJV  ENR  19 11 08
0004  T > IUSMHRPEAQTVDYWGJFC(K)BLOZNX  ENS  19 11 09
0005  I > WMVXQRLS(P)YOGBTKIEFHNZCADJU  ENT  19 11 10
0006  N > WKIQXNRSCVBOY(F)LUDGHZPJAEMT  ENU  19 11 11
0007  G > RVPTWS(L)KYXHGNMQCOAFDZBEJIU  ENV  19 11 12Watch the machine as it runs for 500 steps:>>> cfg.print_operation(steps=500, show_step=True, format='internal', overwrite=True)Functionality: command lineA command line script,enigma.py, provides almost all the functionality of the API.Encode messages:$ enigma.py encode "B-I-III-I EMO UX.MO.AY 13.04.11" "TESTINGXTESTINGUD"
OZQKPFLPYZRPYTFVU

$ enigma.py encode "B-I-III-I EMO UX.MO.AY 13.04.11" "OZQKPFLPYZRPYTFVU"
TESTINGXTESTINGUDShow configuration details (explained in more detail in the command line help):$ enigma.py show "B-I-III-I EMO UX.MO.AY 13.04.11" -l 'X' -H'()' -f internal
X > ABCDEFGHIJKLMNOPQRSTUVW(X)YZ
  P YBCDEFGHIJKLONMPQRSTXVW(U)AZ         UX.MO.AY
  1 HCZMRVJPKSUDTQOLWEXN(Y)FAGIB  O  05  I
  2 KOMQEPVZNXRBDLJHFSUWYACT(G)I  M  10  III
  3 AXIQJZ(K)RMSUNTOLYDHVBWEGPFC  E  19  I
  R YRUHQSLDPX(N)GOKMIEBFZCWVJAT         B
  3 ATZQVYWRCEGOI(L)NXDHJMKSUBPF         I
  2 VLWMEQYPZOA(N)CIBFDKRXSGTJUH         III
  1 WZBLRVXAYGIPD(T)OHNEJMKFQSUC         I
  P YBCDEFGHIJKLONMPQRS(T)XVWUAZ         UX.MO.AY
T < CNAUJVQSLEMIKBZRGPHXDFY(T)WOSimulate machine operation (explained in more detail command line help):$ enigma.py run "B-I-III-I EMO UX.MO.AY 13.04.11" -m "TESTING" -t -H'()'
0000       CNAUJVQSLEMIKBZRGPHXDFYTWO   EMO  19 10 05
0001  T > UNXKGVERLYDIQBTWMHZ(O)AFPCJS  EMP  19 10 06
0002  E > QTYJ(Z)XUPKDIMLSWHAVNBGROFCE  EMQ  19 10 07
0003  S > DMXAPTRWKYINBLUESG(Q)FOZHCJV  ENR  19 11 08
0004  T > IUSMHRPEAQTVDYWGJFC(K)BLOZNX  ENS  19 11 09
0005  I > WMVXQRLS(P)YOGBTKIEFHNZCADJU  ENT  19 11 10
0006  N > WKIQXNRSCVBOY(F)LUDGHZPJAEMT  ENU  19 11 11
0007  G > RVPTWS(L)KYXHGNMQCOAFDZBEJIU  ENV  19 11 12Watch the machine as it runs for 500 steps:$ enigma.py run  "c-β-VIII-VII-VI QMLI 'UX.MO.AY 01.13.04.11" -s 500 -t -f internal -oDocumentationFull documentation is available atRead the Docs.Command line documentation is available as help from the command line script:$ enigma.py --helpLimitationsNote that the correct display of some characters used to represent
components (thin Naval rotors) assumes support for Unicode, while some
aspects of the display of machine state depend on support for combining
Unicode. This is aknown
limitationthat
will be addressed in a future release.Note also that at the start of any scripts that use this package, you shouldfrom __future__ import unicode_literalsbefore any code that uses the API, or confiure IPython (inipython_config.py) withc.InteractiveShellApp.exec_lines += ["from __future__ import unicode_literals"]or explicitly suppply Unicode strings (e.g., as in the examples above withu'TESTING').AlternativesFor other Python Enigma machines see:py-enigma(Python 3)This package is based on aHaskell version, with essentially the same API.Development statusThis package is in the early stages of development, and I and can’t promise the currentdevelopment versionwill work. More detail about planned releases and activities
can be found the list of scheduledmilestonesand in the list ofopen issues.
Varioustest versionsmay be available for installation or issues review, but these also
may not work as expected.