Welcome to Epygma’s documentation!

Contents:

Epygma

The project

https://bitbucket.org/deusyss/epygma/overview

This project was created at the beginning of the 2017 year.

Todo

to complete

About the authors

GALODE Alexandre

Breizh Citizen (Fr)

Member of website Developpez.com, and Python expert. He works everyday on Python project for various customers. Passionates by technic and history, this project was an opportunity to conciliate both passions.

FOURNIS Erwan

Breizh Citizen (Fr)

History professor, expert in WWI, WWII and Napoleon periods.

Licence

All the delivered code is under licence GPLV3. So you use code at your own risk. Authors made for the better, using dedicated tools and serious research, to guarantee as better as possible the best code quality and reporoduced the most exactly ENIGMA comportment.

Tools used

To guarantee a optimal code quality, we used Pylint, and McCabe packages. All the code was written under Pycharm Communauty IDE. ”.idea” directory is present on the bitbucket repository.

About historical realism of ENIGMA devices, we made many research to be as precised as possible. Feel free to contact us if you think there is a problem somewhere in the code.

History Of Enigma

Todo

to complete

How Enigma Works

Todo

to complete

Before starting explanation, you could do a right click on pictures and ask to display picture to see it bigger.

Gloassary

  • Scrambler: reflector + rotors + stator
  • Steckers: invert letters by pair
  • Stator: Static rotor which is used to convert alphabet/rotor. Named “EnTrittsWalze” in Deutch, resumed “ETW”.
  • Rotor:
  • Reflector: rotor, static or not, which allows to make the signal back to rotors. Named “UmKehrWalze” in Deutsch, resumed “UKW”.

Global work

_images/basic_works2.png

Global work is the following. User press a key. Electric signal pass through steckers (1) then go to the scrambler (2). Signal pass through stator and rotors (3, 4, 5, 6), then pass back (7, 8, 9, 10). After what signal pass through again steckers (11). Finally, signal is used to light on the right lamp.

More precise work

_images/basic_works.png

User press a letter, “W” in our example. First it passes the stator. Here no convertion with it. In output, we get a “W”. Then we pass through the rotor III. It converts table (read it from left to right) converts “W” to “C”.Rotor II converts “C” into “M” then Rotor I convert “M” to “Z”. Reflector converts “Z” to “T”, and return it to Rotor I.

Rotor I converts “T” to “J” (convert table work from right to left), then Rotor II converts “J” to “Z”, and Rotor II “Z” to “F”. So the “W” was converted to “F”.

At this moment, Rotor III turns. So if we press again “W”, this time we’d get “W” converted to “O”.

Now return to first schema, and try with “F” letter. In output, we get “W” letter. So Enigma can be reversed with the same start configuation.

Cran = notch

Epygma Architecture

Todo

to complete

Code documentation

TODO

class epygma.epygma.Epygma(cfg_dict=None, device=None)

TODO

convert(text)

Encrypt a letter or an entire text

Parameters:text (str) – the text (or letter) to encrypt
Returns:the encrypted text
extract_cfg()

Extract the rotors and steckers configuration from the complete configuration communicated

load_cfg(cfg_json)

Load the given configuration. Start by check its schema, then if ok, create the configuration

Parameters:cfg_json (file) – the json to load
reset()

TODO :return:

TODO

class epygma.components.reflector.Reflector(model)

TODO

convert(letter_in)

Convert an input letter into another through reflector. Reference is alphabet

Parameters:letter_in (str) – the letter to convert
Returns:the converted letter
Return type:str
reset()

Allows to replace the rotor in its initial state

rotate()

Simulate a rotation of the rotor and increment its counter

set_offset(letter_offset)
Parameters:letter_offset
Returns:
set_start_letter(start_letter)

Define on which letter rotor must be set for first convertion

Parameters:start_letter (str) – the letter on chich start the rotation

TODO

class epygma.components.rotor.Rotor(model)

Allows to simulate a rotor and drive each rotor created

convert_out(letter_in)

Convert a letter into another, from reflector to output. Reference is rotor.

Parameters:letter_in (str) – the letter to convert
Returns:the converted letter
Return type:str

TODO

class epygma.components.stator.Stator(model)

Allows to simulate a stator and drive each rotor created

convert_out(letter_in)

Convert a letter into another, from reflector to output. Reference is rotor.

Parameters:letter_in (str) – the letter to convert
Returns:the converted letter
Return type:str

TODO

class epygma.components.scrambler.Scrambler(cfg_json)

Allows to create and simulate an assembly of rotors and a reflector, and their rotations. Scrambler contains static rotor, dynamic rotor and reflector.

convert(letter_in)

Convert an incoming letter into another, through rotors and reflector.

Parameters:letter_in (str) – the letter to convert
Returns:all the converted letters for historic
Return type:list
reset_cfg()

Allows to reset the configuration of the rotors assembly, so you can reload another one

TODO

class epygma.components.stecker.Stecker(list_steckers=None)

This class allows to simulate Stecker of Enigma engine.

Stecker was used to invert couple of letters. Max number of Stecker: 13 (26/2)

convert(letter_in)

Use all defined Stecker to convert letter. Check for each letter if there is an invertion. If yes, we check the following letter, else we return the last convertion.

Parameters:letter_in (str) – the letter to convert
Returns:the converted letter after alls teckers
Return type:str
get()

Allows to get the inverted letters

Returns:the Stecker names and associated letters
Return type:dict
remove(name=None, letter=None)

Allows to remove a previously defined stecker by name or by letter. Name is test in first.

Parameters:
  • name (str) – the name of the stecker to remove
  • letter (str) – the letter to disconnect. Use only if name is not defined
reset()

Allows to remove all the set Stecker on the engine

set(letter_one, letter_two, name)

Allows to set a new stecker. Assertion are made on letter and name, which are mandatory

Parameters:
  • letter_one (str) – first letter for connection
  • letter_two (str) – second letter for connection
  • name (str) – the name of the stecker

Sources

Books

Todo

to complete