Skip to main content

Python Enigma cypher machine simulator.

Project description

pyEnigma

pyEnigma is a Python Enigma cypher machine simulator.

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

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

pyenigma-1.0.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyenigma-1.0.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file pyenigma-1.0.0.tar.gz.

File metadata

  • Download URL: pyenigma-1.0.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyenigma-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e349bd69905ebbab1cbeae6102575026ec575dbcca3140d8fd3360e76d61543f
MD5 a7dcfa4919f61df129168d9afb9ef876
BLAKE2b-256 5c90da3b0bb58e8e1359d2d770dbb42a46fc4f42da67556a5b10e2df0c6fdccd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyenigma-1.0.0.tar.gz:

Publisher: release.yml on cedricbonhomme/pyEnigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyenigma-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyenigma-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyenigma-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 faa2567f021f715930a8e873875c8645b03c82ba8a5ed7b2443f735cbdc67303
MD5 870df9b43ffd32f1ca3acaf6f0c6a729
BLAKE2b-256 9ebdd2d05e9311a10a6d24b9a272d63bbda4b193b812babcc467920b10553574

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyenigma-1.0.0-py3-none-any.whl:

Publisher: release.yml on cedricbonhomme/pyEnigma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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