enigmachine


Nameenigmachine JSON
Version 0.4 PyPI version JSON
download
home_page
SummaryEngima chiper machine
upload_time2024-02-10 15:32:22
maintainer
docs_urlNone
authorFernando Cortés
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Enigma


![logo](https://github.com/Fer14/enigmachine/logos/white.png)

A simple Python-library of the famous enigma machine.

## Requirements

To run this code, you need:

    Python 3.x

## Usage


```python
enigma_sender = EnigmaMachine(
    rotor_wirings=[
        "BDFHJLCPRTXVZNYEIWGAKMUSQO",
        "AJDKSIRUXBLHWTMCQGZNPYFVOE",
        "EKMFLGDQVZNTOWYHXUSPAIBRCJ",
    ],
    rotor_offsets=[0, 0, 0],
    reflector_wirings='YRUHQSLDPXNGOKMIEBFZCWVJAT'
)
encripted_msg = enigma_sender.encrypt("HELLO")

enigma_receiver = EnigmaMachine(
    rotor_wirings=[
        "BDFHJLCPRTXVZNYEIWGAKMUSQO",
        "AJDKSIRUXBLHWTMCQGZNPYFVOE",
        "EKMFLGDQVZNTOWYHXUSPAIBRCJ",
    ],
    rotor_offsets=[0, 0, 0],
    reflector_wirings='YRUHQSLDPXNGOKMIEBFZCWVJAT')


decripted_msg = enigma_receiver.encrypt(encripted_msg)

assert decripted_msg == "HELLO"

```

## Configuration

The EnigmaMachine class takes the following parameters:
* `rotor_wirings`:  A list of strings, each string represents the wiring of a rotor. The first string is the wiring of the rightmost rotor, the second string is the wiring of the middle rotor, and the third string is the wiring of the leftmost rotor. The wiring is a permutation of the 26 letters of the alphabet.

* `rotor_offsets`: A list of integers, each integer represents the initial position of a rotor. The first integer is the initial position of the rightmost rotor, the second integer is the initial position of the middle rotor, and the third integer is the initial position of the leftmost rotor. The initial position is a number between 0 and 25.

* `reflector_wirings`: A string representing the wiring of the reflector. The wiring is a permutation of the 26 letters of the alphabet.

* `plugboard_connections`: A dictionary representing the connections of the plugboard. The keys are the letters of the alphabet, and the values are the letters that they are connected to. For example, if the value of the key "A" is "Z", it means that the letter "A" is connected to the letter "Z".

* `rotor_names`: A list of strings, each string represents the name of a rotor. The first string is the name of the rightmost rotor, the second string is the name of the middle rotor, and the third string is the name of the leftmost rotor. The name of a rotor is a string of 26 letters, each letter represents the position of the rotor when the letter "A" is at the top position.

* `reflector_name`: Name of the reflector.

## Predefined Machines

The library comes with a set of predefined machines that you can use. The machines can be seen [here](https://github.com/Fer14/enigmachine/blob/main/enigma/configurations.py)

```python
enigma = EnigmaMachine.from_configuration(
    rotor_config=ROTOR_CONFIGURATIONS['Commercial Enigma A, B'],
    rotor_offsets = [0,0,0],
    reflector_config=REFLECTOR_CONFIGURATIONS['A'],
    plugboard_wirings = {}
)
```



## Custom Machine

Alternatively, you can build you own custom machine with your own set of components, by using the `Rotor`, `Reflector`, and `Plugboard` classes. The following components are available:


```python

custom_machine = Machine(
    [
        PlugBoard(wiring={"A":"B"}),
    Rotor(wiring="EKMFLGDQVZNTOWYHXUSPAIBRCJ",offset=0),
    Reflector(wiring="YRUHQSLDPXNGOKMIEBFZCWVJAT")
    ]
)
```

You can watch an example of usage in the following [notebook](https://github.com/Fer14/enigmachine/blob/main/examples.ipynb)


## Contributing

If you would like to contribute to this project, please follow these steps:

- Fork the repository on GitHub.
- Clone the forked repository to your local machine.
- Create a new branch for your feature or bug fix.
- Implement your changes and test them.
- Commit your changes with descriptive commit messages.
- Push the changes to your fork on GitHub.
- Create a pull request to the original repository.


## References

The references that help me build this library are:
- https://www.youtube.com/watch?v=ybkkiGtJmkM&t=245s
- https://www.codesandciphers.org.uk/enigma/example1.htm
- https://www.youtube.com/watch?v=Kz6IlDCyOUY

![logos](https://github.com/Fer14/enigmachine/logos/black.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "enigmachine",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Fernando Cort\u00e9s",
    "author_email": "fcsancho14@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/54/2e/0436304c2e05fac3fdf98cd163293b4f93e7f9e2ce3b2da1ad275ecd0136/enigmachine-0.4.tar.gz",
    "platform": null,
    "description": "# Enigma\n\n\n![logo](https://github.com/Fer14/enigmachine/logos/white.png)\n\nA simple Python-library of the famous enigma machine.\n\n## Requirements\n\nTo run this code, you need:\n\n    Python 3.x\n\n## Usage\n\n\n```python\nenigma_sender = EnigmaMachine(\n    rotor_wirings=[\n        \"BDFHJLCPRTXVZNYEIWGAKMUSQO\",\n        \"AJDKSIRUXBLHWTMCQGZNPYFVOE\",\n        \"EKMFLGDQVZNTOWYHXUSPAIBRCJ\",\n    ],\n    rotor_offsets=[0, 0, 0],\n    reflector_wirings='YRUHQSLDPXNGOKMIEBFZCWVJAT'\n)\nencripted_msg = enigma_sender.encrypt(\"HELLO\")\n\nenigma_receiver = EnigmaMachine(\n    rotor_wirings=[\n        \"BDFHJLCPRTXVZNYEIWGAKMUSQO\",\n        \"AJDKSIRUXBLHWTMCQGZNPYFVOE\",\n        \"EKMFLGDQVZNTOWYHXUSPAIBRCJ\",\n    ],\n    rotor_offsets=[0, 0, 0],\n    reflector_wirings='YRUHQSLDPXNGOKMIEBFZCWVJAT')\n\n\ndecripted_msg = enigma_receiver.encrypt(encripted_msg)\n\nassert decripted_msg == \"HELLO\"\n\n```\n\n## Configuration\n\nThe EnigmaMachine class takes the following parameters:\n* `rotor_wirings`:  A list of strings, each string represents the wiring of a rotor. The first string is the wiring of the rightmost rotor, the second string is the wiring of the middle rotor, and the third string is the wiring of the leftmost rotor. The wiring is a permutation of the 26 letters of the alphabet.\n\n* `rotor_offsets`: A list of integers, each integer represents the initial position of a rotor. The first integer is the initial position of the rightmost rotor, the second integer is the initial position of the middle rotor, and the third integer is the initial position of the leftmost rotor. The initial position is a number between 0 and 25.\n\n* `reflector_wirings`: A string representing the wiring of the reflector. The wiring is a permutation of the 26 letters of the alphabet.\n\n* `plugboard_connections`: A dictionary representing the connections of the plugboard. The keys are the letters of the alphabet, and the values are the letters that they are connected to. For example, if the value of the key \"A\" is \"Z\", it means that the letter \"A\" is connected to the letter \"Z\".\n\n* `rotor_names`: A list of strings, each string represents the name of a rotor. The first string is the name of the rightmost rotor, the second string is the name of the middle rotor, and the third string is the name of the leftmost rotor. The name of a rotor is a string of 26 letters, each letter represents the position of the rotor when the letter \"A\" is at the top position.\n\n* `reflector_name`: Name of the reflector.\n\n## Predefined Machines\n\nThe library comes with a set of predefined machines that you can use. The machines can be seen [here](https://github.com/Fer14/enigmachine/blob/main/enigma/configurations.py)\n\n```python\nenigma = EnigmaMachine.from_configuration(\n    rotor_config=ROTOR_CONFIGURATIONS['Commercial Enigma A, B'],\n    rotor_offsets = [0,0,0],\n    reflector_config=REFLECTOR_CONFIGURATIONS['A'],\n    plugboard_wirings = {}\n)\n```\n\n\n\n## Custom Machine\n\nAlternatively, you can build you own custom machine with your own set of components, by using the `Rotor`, `Reflector`, and `Plugboard` classes. The following components are available:\n\n\n```python\n\ncustom_machine = Machine(\n    [\n        PlugBoard(wiring={\"A\":\"B\"}),\n    Rotor(wiring=\"EKMFLGDQVZNTOWYHXUSPAIBRCJ\",offset=0),\n    Reflector(wiring=\"YRUHQSLDPXNGOKMIEBFZCWVJAT\")\n    ]\n)\n```\n\nYou can watch an example of usage in the following [notebook](https://github.com/Fer14/enigmachine/blob/main/examples.ipynb)\n\n\n## Contributing\n\nIf you would like to contribute to this project, please follow these steps:\n\n- Fork the repository on GitHub.\n- Clone the forked repository to your local machine.\n- Create a new branch for your feature or bug fix.\n- Implement your changes and test them.\n- Commit your changes with descriptive commit messages.\n- Push the changes to your fork on GitHub.\n- Create a pull request to the original repository.\n\n\n## References\n\nThe references that help me build this library are:\n- https://www.youtube.com/watch?v=ybkkiGtJmkM&t=245s\n- https://www.codesandciphers.org.uk/enigma/example1.htm\n- https://www.youtube.com/watch?v=Kz6IlDCyOUY\n\n![logos](https://github.com/Fer14/enigmachine/logos/black.png)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Engima chiper machine",
    "version": "0.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "776395edc5c90bea38cfcc827d5cbf6c8c1a4718a080fe4d0658bebc8c2d9755",
                "md5": "dfc0dfc50932b8f5f8fe3ba008005d0b",
                "sha256": "c1804768fa19cce9fbf5778c474ecc14c449f51a540ef2f481e8dc430cd4fe83"
            },
            "downloads": -1,
            "filename": "enigmachine-0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dfc0dfc50932b8f5f8fe3ba008005d0b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8420,
            "upload_time": "2024-02-10T15:32:20",
            "upload_time_iso_8601": "2024-02-10T15:32:20.299424Z",
            "url": "https://files.pythonhosted.org/packages/77/63/95edc5c90bea38cfcc827d5cbf6c8c1a4718a080fe4d0658bebc8c2d9755/enigmachine-0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "542e0436304c2e05fac3fdf98cd163293b4f93e7f9e2ce3b2da1ad275ecd0136",
                "md5": "2806f8e7392d6366366b9b5ea9d01058",
                "sha256": "1b7ba189eea30b896250954cde63d9835426fed4a4632adbef0917d9715e11a3"
            },
            "downloads": -1,
            "filename": "enigmachine-0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2806f8e7392d6366366b9b5ea9d01058",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8856,
            "upload_time": "2024-02-10T15:32:22",
            "upload_time_iso_8601": "2024-02-10T15:32:22.471115Z",
            "url": "https://files.pythonhosted.org/packages/54/2e/0436304c2e05fac3fdf98cd163293b4f93e7f9e2ce3b2da1ad275ecd0136/enigmachine-0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-10 15:32:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "enigmachine"
}
        
Elapsed time: 0.19438s