Skip to main content

A simple yet faithful library to emulate different Enigma machines models using Python

Project description

Enigma Python library

drawing

About

Welcome to enigmapython, a Python package designed to emulate the legendary Enigma cryptographic machine used during World War II. enigmapython provides a faithful implementation of the Enigma machine, allowing users to explore and understand the workings of this historic device.

Key Features

  • Flexible Configuration: enigmapython allows customization of the Enigma machine configuration, enabling users to experiment with different rotor settings, reflectors, and ring positions.
  • Easy Extension: enigmapython is designed to be easily extensible, allowing developers to add new features or enhance the existing implementation.
  • Simple yet faithful: don't be fooled by its simplicity; enigmapython implements 100% the algorithms of many Enigma machine models, allowing to decode a message that has been encoded by a real Enigma machine and also the contrary.

Machines implementations

The following Enigma machine models (along with their rotors, reflectors and plugboards) have been implemented:

Enigma B (Sweden, s/n: A-133)*

Scrambler Wiring Notch Implemented
ETW (passthrough) abcdefghijklmnopqrstuvxyzåäö N/A
Rotor I psbgöxqjdhoäucfrtezvåinlymka ä
Rotor II chnsyöadmotrzxbäigåekqupflvj ä
Rotor III åvqiaäxrjbözspcfyunthdomekgl ä
Reflector UKW ldgbäncpskjavfzhxuiårmqöotey N/A

*given the rarity of this model and the little documentation/simulators available, although I expect an encryption consistency on par with newer models, I was unable to test it as I would have liked

Enigma D

Scrambler Wiring Notch Implemented
ETW "QWERTZ" qwertzuioasdfghjkpyxcvbnml N/A
ETW "JWULCM" jwulcmnohpqzyxiradkegvbtsf N/A
Rotor I lpgszmhaeoqkvxrfybutnicjdw y
Rotor II slvgbtfxjqohewirzyamkpcndu e
Rotor III bdfhjlcprtxvznyeiwgakmusqo n
Reflector UKW imetcgfraysqbzxwlhkdvupojn N/A

Enigma Z (Z30 Mark I)*

Scrambler Wiring Notch Implemented
ETW (passthrough) 1234567890 N/A
Rotor I 6418270359 9
Rotor II 5841097632 9
Rotor III 3581620794 9
Reflector UKW 5079183642 N/A

*given the rarity of this model and the little documentation/simulators available, although I expect an encryption consistency on par with newer models, I was unable to test it as I would have liked

Enigma I

Scrambler Wiring Notch Implemented
Plugboard (passthrough+swappable) N/A N/A
ETW (passthrough) abcdefghijklmnopqrstuvwxyz N/A
Rotor I ekmflgdqvzntowyhxuspaibrcj q
Rotor II ajdksiruxblhwtmcqgznpyfvoe e
Rotor III bdfhjlcprtxvznyeiwgakmusqo v
Reflector A ejmzalyxvbwfcrquontspikhgd N/A
Reflector B yruhqsldpxngokmiebfzcwvjat N/A
Reflector C fvpjiaoyedrzxwgctkuqsbnmhl N/A

Enigma I Norway (Norenigma)

Scrambler Wiring Notch Implemented
Plugboard (passthrough+swappable) N/A N/A
ETW (passthrough) abcdefghijklmnopqrstuvwxyz N/A
Rotor I wtokasuyvrbxjhqcpzefmdinlg q
Rotor II gjlpubswemctqvhxaofzdrkyni e
Rotor III jwfmhnbpusdytixvzgrqlaoekc v
Rotor IV fgzjmvxepbwshqtliudykcnrao j
Rotor V hejxqotzbvfdascilwpgynmurk z
Reflector UKW mowjypuxndsraibfvlkzgqchet N/A

Enigma I Sondermaschine (special machine)

Scrambler Wiring Notch Implemented
Plugboard (passthrough+swappable) N/A N/A
ETW (passthrough) abcdefghijklmnopqrstuvwxyz N/A
Rotor I veosirzujdqckgwypnxaflthmb q
Rotor II uemoatqlshpkcyfwjzbgvxidnr e
Rotor III tzhxmbsipnurjfdkeqvcwglaoy v
Reflector UKW ciagsndrbytpzfulvhekoqxwjm N/A

Enigma M3

Scrambler Wiring Notch Implemented
Plugboard (passthrough+swappable) N/A N/A
ETW (passthrough) abcdefghijklmnopqrstuvwxyz N/A
Rotor I ekmflgdqvzntowyhxuspaibrcj q
Rotor II ajdksiruxblhwtmcqgznpyfvoe e
Rotor III bdfhjlcprtxvznyeiwgakmusqo v
Rotor IV esovpzjayquirhxlnftgkdcmwb j
Rotor V vzbrgityupsdnhlxawmjqofeck z
Rotor VI jpgvoumfyqbenhzrdkasxlictw m, z
Rotor VII nzjhgrcxmyswboufaivlpekqdt m, z
Rotor VIII fkqhtlxocbjspdzramewniuygv m, z
Reflector B yruhqsldpxngokmiebfzcwvjat N/A
Reflector C fvpjiaoyedrzxwgctkuqsbnmhl N/A

Enigma M4

Scrambler Wiring Notch Implemented
Plugboard (passthrough+swappable) N/A N/A
ETW (passthrough) abcdefghijklmnopqrstuvwxyz N/A
Rotor I ekmflgdqvzntowyhxuspaibrcj q
Rotor II ajdksiruxblhwtmcqgznpyfvoe e
Rotor III bdfhjlcprtxvznyeiwgakmusqo v
Rotor IV esovpzjayquirhxlnftgkdcmwb j
Rotor V vzbrgityupsdnhlxawmjqofeck z
Rotor VI jpgvoumfyqbenhzrdkasxlictw m, z
Rotor VII nzjhgrcxmyswboufaivlpekqdt m, z
Rotor VIII fkqhtlxocbjspdzramewniuygv m, z
Beta leyjvcnixwpbqmdrtakzgfuhos N/A
Gamma fsokanuerhmbtiycwlqpzxvgjd N/A
Reflector B Thin enkqauywjicopblmdxzvfthrgs N/A
Reflector C Thin rdobjntkvehmlfcwzaxgyipsuq N/A

Prerequisites

  • Python 3.11
  • Clone this repo, checkout the desired branch/tag and install requirements (pip install -r requirements.txt) or directly from PyPI using pip install enigmapython

Getting started

Please have a look of the examples folder

Documentation

An initial documentation draft can be found here, but in most cases examples, code (and comments) are better than the documentation

Known implementations

Here's a list containing all the known Enigma simulators that use the enigmapython API.

  • Enigma TUI. Enigma TUI is a Terminal User Interface for Enigma machines, allowing you to simulate different Enigma machine models from the terminal. It employs enigmapython as Enigma engine.
drawing
drawing

In the case you leveraged enigmapython API in a project, either public or not, drop me an email at denis.maggiorotto[at]gmail.com and I'll be happy to list you here.

Credits/references

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enigmapython-1.2.3.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

enigmapython-1.2.3-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file enigmapython-1.2.3.tar.gz.

File metadata

  • Download URL: enigmapython-1.2.3.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for enigmapython-1.2.3.tar.gz
Algorithm Hash digest
SHA256 742bf199d9cb4da0206257fcf212e1fa73204fc8d430551df13acdda83b82224
MD5 c3c584121c14e792c1901d1e9fe74762
BLAKE2b-256 df17473d6e282c92ce2f500470ac554f25da567aed61fbe33bb255bd000ac6f2

See more details on using hashes here.

File details

Details for the file enigmapython-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: enigmapython-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for enigmapython-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 771751a46c71038ffe63dbf3a553e61991201d76ad39633ab1d5c78ca2bc7086
MD5 f02fc38a2487e3a097d08a0e7553248f
BLAKE2b-256 b696ef555ae19f12355d18cd167167d381f099d0d74d9afdca946f587008ca30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page