logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

pyenigma.py - encrypt/decrypt text according to Enigma machine key settings

Author

       Brian Neal <bgneal@gmail.com>

                                                   26 Apr 2015                                    pyenigma.py(1)

Description

       pyenigma.py is a command line for processing Enigma messages.  Enigma settings can either be specified by
       command-line  arguments,  or  read from a key file. If reading from a key file, the line labeled with the
       current day number is used unless the --day argument is provided.

       Text to process can be supplied 3 ways:

              •  if --text=TEXT is present TEXT is processed

              •  if --file=FILE is present the contents of FILE are processed

              •  otherwise the text is read from standard input

       Please see documentation for the description of the file format.

Example

       Try these commands to specify settings from the command line:

           $ pyenigma.py -r III IV V -i 1 2 3 -p AB CD EF GH IJ KL MN -u B -s XYZ
           $ pyenigma.py -r Beta III IV V -i A B C D -p 1/2 3/4 5/6 -u B-Thin -s WXYZ

       This command will load Enigma settings from a file:

           $ pyenigma.py --key-file=enigma.keys -s XYZ -t HELLOXWORLDX

Name

pyenigma.py - encrypt/decrypt text according to Enigma machine key settings

Options

-h,--help
              show this help message and exit

       -kKEY_FILE,--key-fileKEY_FILE
              path to key file for daily settings

       -dDAY,--dayDAY
              use the settings for day DAY when reading key file

       -rROTOR[ROTOR...],--rotorsROTOR[ROTOR...]
              rotor list ordered from left to right; e.g III IV I

       -iRING_SETTING[RING_SETTING...],--ring-settingsRING_SETTING[RING_SETTING...]
              ring setting list from left to right; e.g. A A J

       -pPLUGBOARD[PLUGBOARD...],--plugboardPLUGBOARD[PLUGBOARD...]
              plugboard settings

       -uREFLECTOR,--reflectorREFLECTOR
              reflector name

       -sSTART,--startSTART
              starting position

       -tTEXT,--textTEXT
              text to process

       -fFILE,--fileFILE
              input file to process

       -xREPLACE_CHAR,--replace-charREPLACE_CHAR
              if the input text contains chars not  found  on  the  enigma  keyboard,  replace  with  this  char
              [default: X]

       -z,--delete-chars
              if the input text contains chars not found on the enigma keyboard, delete them from the input

       -v,--verbose
              provide verbose output; include final rotor positions

Synopsis

       pyenigma.py [-h] [-kKEY_FILE] [-dDAY] [-rROTOR [ROTOR ...]]
                   [-iRING_SETTING [RING_SETTING ...]]
                   [-pPLUGBOARD [PLUGBOARD ...]] [-uREFLECTOR] [-sSTART]
                   [-tTEXT] [-fFILE] [-xREPLACE_CHAR] [-z] [-v]

See Also