Python Enigma cypher machine simulator.
Project description
pyEnigma
pyEnigma is a Python Enigma cypher machine simulator.
For reporting issues, visit the tracker here: https://todo.sr.ht/~cedric/pyenigma
Usage
As a Python library
You can install pyEnigma with Poetry.
$ poetry install pyenigma
Then you can use it in your program:
$ poetry shell
(pyenigma-py3.12) $
(pyenigma-py3.12) $ python
Python 3.12.1 (main, Dec 31 2023, 00:21:59) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyenigma import enigma
>>> from pyenigma import rotor
>>> print(rotor.ROTOR_GR_III)
Name: III
Model: German Railway (Rocket)
Date: 7 February 1941
Wiring: JVIUBHTCDYAKEQZPOSGXNRMWFL
>>>
>>> engine = enigma.Enigma(rotor.ROTOR_Reflector_A, rotor.ROTOR_I,
rotor.ROTOR_II, rotor.ROTOR_III, key="ABC",
plugs="AV BS CG DL FU HZ IN KM OW RX")
>>> print(engine)
Reflector:
Name: Reflector A
Model: None
Date: None
Wiring: EJMZALYXVBWFCRQUONTSPIKHGD
Rotor 1:
Name: I
Model: Enigma 1
Date: 1930
Wiring: EKMFLGDQVZNTOWYHXUSPAIBRCJ
State: A
Rotor 2:
Name: II
Model: Enigma 1
Date: 1930
Wiring: AJDKSIRUXBLHWTMCQGZNPYFVOE
State: B
Rotor 3:
Name: III
Model: Enigma 1
Date: 1930
Wiring: BDFHJLCPRTXVZNYEIWGAKMUSQO
State: C
>>> secret = engine.encipher("Hello World")
>>> print(secret)
Qgqop Vyzxp
As a program
Install pyEnigma system wide with pipx:
$ pipx install pyenigma
Then you can use the command line interface:
$ echo "Hello World" | enigma ABC A I II III "AV BS CG DL FU HZ IN KM OW RX"
Qgqop Vyzxp
$ echo "Qgqop Vyzxp" | enigma ABC A I II III "AV BS CG DL FU HZ IN KM OW RX"
Hello World
If you want to display the rotor output state:
$ echo "Hello World" | enigma ABC A I II III "AV BS CG DL FU HZ IN KM OW RX" --verbose
Qgqop Vyzxp
KBC A I II III "AV BS CG DL FU HZ IN KM OW RX"
The state is returned on stderr
, so you can still use the Unix pipe mechanism:
$ echo "Hello World" | enigma ABC A I II III "AV BS CG DL FU HZ IN KM OW RX" --verbose | enigma ABC A I II III "AV BS CG DL FU HZ IN KM OW RX"
KBC A I II III "AV BS CG DL FU HZ IN KM OW RX"
Hello World
License
pyEnigma is licensed under GNU General Public License version 3
Author
- Christophe Goessen (initial author)
- Cédric Bonhomme
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyenigma-0.4.2.tar.gz
(18.5 kB
view details)
Built Distribution
pyenigma-0.4.2-py3-none-any.whl
(33.3 kB
view details)
File details
Details for the file pyenigma-0.4.2.tar.gz
.
File metadata
- Download URL: pyenigma-0.4.2.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.4 Linux/6.1.0-17-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c1309808a71ade95d79e506a7faab3a897c0a3dc2995cec34f7a3333abd3d2c |
|
MD5 | 1fe7ca04484aa7542b1051dfe8ee552f |
|
BLAKE2b-256 | 267c04b4f06fb9a4bd345ec2c92edd2c873535775f7d7732bb8f264275772d5f |
File details
Details for the file pyenigma-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: pyenigma-0.4.2-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.4 Linux/6.1.0-17-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9830e037f447e5d9c6d296e513aa6be335c57148c2dc5ba24f91aec3f9a0e1f |
|
MD5 | 2016d2c7abbfc3cf3886d4d9ec37b1ff |
|
BLAKE2b-256 | 9df015123d696c195919ebfb42c2f2245db9591a505b04ed579a15d74aae60b9 |