{"id":19520333,"url":"https://github.com/henryhale/enigma","last_synced_at":"2025-07-19T15:04:13.834Z","repository":{"id":213752283,"uuid":"734764031","full_name":"henryhale/enigma","owner":"henryhale","description":"🔐 A basic simulation of the Enigma machine","archived":false,"fork":false,"pushed_at":"2024-06-06T06:27:47.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-14T04:41:05.431Z","etag":null,"topics":["cipher","cryptography","decryption","encryption","enigma","enigma-machine","enigma-simulator","henryhale","ts","turing"],"latest_commit_sha":null,"homepage":"https://henryhale.github.io/enigma/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henryhale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-22T14:51:53.000Z","updated_at":"2024-06-06T06:27:51.000Z","dependencies_parsed_at":"2024-11-14T06:46:03.614Z","dependency_job_id":null,"html_url":"https://github.com/henryhale/enigma","commit_stats":null,"previous_names":["henryhale/enigma"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/henryhale/enigma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryhale%2Fenigma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryhale%2Fenigma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryhale%2Fenigma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryhale%2Fenigma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henryhale","download_url":"https://codeload.github.com/henryhale/enigma/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryhale%2Fenigma/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265950399,"owners_count":23853753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cipher","cryptography","decryption","encryption","enigma","enigma-machine","enigma-simulator","henryhale","ts","turing"],"created_at":"2024-11-11T00:25:00.730Z","updated_at":"2025-07-19T15:04:13.817Z","avatar_url":"https://github.com/henryhale.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=center\u003e\n\n\u003cimg width=60 src=https://upload.wikimedia.org/wikipedia/commons/3/37/Enigma-logo.svg\u003e\n\n# enigma\n\n_The World War II's cryptic game-changer, a mechanical marvel of secrecy and encryption_\n\n\u003c/div\u003e\n\n## Overview\n\nThis repository features a TypeScript simulation of the iconic Enigma machine — _an encryption device used by the German military during World War II._\n\nHaving watched [The Imitation Game](http://theimitationgamemovie.com/) movie with prior understanding of cryptography, I decided to challenge myself into creating a simulation of the basic functionality of the original Enigma machines. Then later try to break it just like Alan Turing and his collegues did.\n\nNow the first step is done 🎉\n\nThe rest of this document tells what I found out and provides a guide to run the simulation on your computer.\n\n## Live Demo\n\nTo try the live demo, first check out how to use it [here](#guide).\n\nCheck out the simulation in action: [Try it Yourself](https://henryhale.github.io/enigma/)\n\n## How it Works\n\nThe Enigma machine consisted of rotors, reflector, plugboard and a keyboard.\nEach key press initiated a complex encryption process involving the rotation of rotors and the reflection of signals.\nIts daily-changing settings posed a significant challenge to Allied codebreakers.\n\nThe process of transforming an input character involves a sequence of steps through various components, including the plugboard, rotors, reflector, and plugboard again before reaching the lampboard.\nHere's a brief description of the transformation pipeline:\n\n1. **Plugboard:**\n\n   - The input character enters the plugboard, where initial letter swaps occur. Pairs of letters are connected, providing an additional layer of complexity to the encryption.\n\n2. **Rotors:**\n\n   - The character then passes through a series of rotors, each with its own internal wiring. As the rotors rotate with each keypress, the electrical signal is further scrambled through these intricate pathways.\n\n3. **Reflector:**\n\n   - After passing through the rotors, the signal is directed to the reflector. The reflector ensures that the signal is then sent back through the rotors in a different path, contributing to the complexity of the encryption.\n\n4. **Rotors (again):**\n\n   - The signal, now reflected, passes through the rotors again in the reverse direction. This double-pass through the rotors adds a crucial non-linearity to the encryption process.\n\n5. **Plugboard (again):**\n\n   - The signal re-enters the plugboard for a second letter swap. This final permutation provides an additional layer of complexity to the output.\n\n6. **Lampboard:**\n   - The transformed signal finally reaches the lampboard, where the illuminated letter represents the encrypted output. This letter corresponds to the final encrypted character.\n\nThe transformation process involves a carefully orchestrated series of steps through various components, creating a highly secure and dynamic encryption process during each keypress.\n\n## Getting Started\n\nFollow these steps to set up and run the Enigma machine simulation on your local machine:\n\n### Prerequisites\n\n- [Node.js](https://nodejs.org/) installed on your machine\n\n### Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/henryhale/enigma.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd enigma\n   ```\n\n3. Install dependencies:\n\n   ```bash\n   npm install\n   # pnpm install\n   ```\n\n## Usage\n\nRun the provided example script to witness the Enigma machine in action:\n\n- Node.js\n\n  ```bash\n  npm run simulate\n  # pnpm simulate\n  ```\n\n- Browser\n\n  ```bash\n  npm run dev\n  # pnpm dev\n  ```\n\nExplore the script to create your own scenarios and delve into different Enigma machine configurations.\n\nTo build the simulation for production, run the provided command\n\n```bash\nnpm run build\n# pnpm build\n```\n\n## Structure\n\n- [source/](./source/): Implementation of the Enigma machine, rotors, plugboard and reflector.\n- [demo/simulate.ts](./demo/simulate.ts): Example script for Node.js.\n- [demo/browser.ts](./demo/browser.ts): Example script for the browser (with [index.html](./index.html))\n\n## Guide\nThis section focuses on the browser demo taking you through how to encrypt and decrypt messages\n\n- Open the demo [locally](#usage) in your browser or check out the [live demo](https://henryhale.github.io/enigma/).\n- `Mode`: Encryption - select the `encrypt` radio button.\n- `Rotors`:  For simplicity, leave each rotor position at `0 - A`. \n   Otherwise set the rotors to the desired positions say `0 - A`, `1 - B`, `2 - C`.\n   Be sure to note the order as it will be used to decrypt the messages.\n- `Lampboard`: Everytime you input a key, the output (ciphered) key will light up.\n- `Input`: Type the plain text message here.\n- `Output`: The output is represented the ciphered text from the input message.\n- `Mode`: Decryption - to decrypt the message, open the demo in another tab and select `decrypt` under the `Mode` section.\n- `Rotors`: Set the rotor positions to the values they were at during encryption.\n- `Input`: Enter the ciphered text into the input textarea.\n- `Output`: The corresponding result is the plaintext you entered during the encryption.\n  \nIf you have reached this point, you have got it 🎉\n \n## Contributing\n\nContributions are welcome! If you have suggestions or improvements, feel free to open an issue or create a pull request.\n\n## References\n\n- How did the Enigma work? [Youtube Video](https://youtu.be/ybkkiGtJmkM)\n- The Imitation Game (2014) - [Film](http://theimitationgamemovie.com/)\n- Enigma Machine - [Wikipedia article](https://en.wikipedia.org/wiki/Enigma_machine)\n- The Enigma Machine - [Crypto Museum](https://www.cryptomuseum.com/crypto/enigma/)\n- _Enigma: The Battle for the Code_ by Hugh Sebag-Montefiore\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](./LICENSE.md) file for details.\n\nCopyright \u0026copy; 2023 [Henry Hale](https://github.com/henryhale)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryhale%2Fenigma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenryhale%2Fenigma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryhale%2Fenigma/lists"}