{"id":15537954,"url":"https://github.com/tfogo/enigma-simulator","last_synced_at":"2025-11-11T23:27:13.514Z","repository":{"id":57225488,"uuid":"79876097","full_name":"tfogo/enigma-simulator","owner":"tfogo","description":"Enigma Machine Simulator for Wehrmacht Enigma I, Kriegsmarine M3 and M4 variants.","archived":false,"fork":false,"pushed_at":"2018-02-28T05:13:37.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-09T12:03:20.029Z","etag":null,"topics":["cryptography","enigma-machine"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfogo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-24T03:47:46.000Z","updated_at":"2024-08-15T13:59:52.000Z","dependencies_parsed_at":"2022-08-24T10:40:22.535Z","dependency_job_id":null,"html_url":"https://github.com/tfogo/enigma-simulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfogo%2Fenigma-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfogo%2Fenigma-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfogo%2Fenigma-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfogo%2Fenigma-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfogo","download_url":"https://codeload.github.com/tfogo/enigma-simulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250458330,"owners_count":21433852,"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":["cryptography","enigma-machine"],"created_at":"2024-10-02T12:00:46.855Z","updated_at":"2025-10-06T05:56:39.625Z","avatar_url":"https://github.com/tfogo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enigma Simulator\nAn npm module for Enigma Machines. It can simulate a Wehrmacht Enigma I and Kriegsmarine M3 and M4 variants.\n\n## Install\n```\nnpm install enigma-simulator\n```\n\n## Example Usage\n\nRequire the `enigma-simulator` module:\n\n```js\nvar enigma = require('enigma-simulator');\n```\n\nCreate a Wehrmacht Enigma I Machine with a B reflector and rotors III, II, I with default positions and ring settings:\n\n```js\nvar e1 = enigma();\ne1.encodeString('ABC'); // 'FUV'\n```\n\nOr create an Enigma machine with your own settings (rotors, positions, ringSettings, reflector, plugboardPairs):\n\n```js\nvar m3 = enigma(['IV', 'I', 'III'], [3, 5, 20], [7, 12, 14], 'C', 'AS TH LR');\nm3.encodeString('ABC'); // 'IRD'\n```\n\nCreate a Kriegsmarine M4 Enigma Machine:\n\n```js\nvar m4 = enigma(['Gamma','III','II','I'], [0,0,0,0], [0,0,0,0], 'BThin');\nm4.encodeString('ABC'); // 'BPF'\n```\n\n## Documentation\n\n### enigma()\n\n#### Syntax\n```\nenigma(rotors, positions, ringSettings, reflector, plugboardPairs)\n```\n\n#### Output\n\nReturns an instance of `EnigmaMachine`.\n\n#### Parameters\n\n**rotors** Optional. An array of strings which represent the rotor types to use in which position (left to right). Available rotors are:\n\n| Rotor | Encoding | Turnover | Notes |\n| --- | --- | --- | --- |\n| `'I'` | EKMFLGDQVZNTOWYHXUSPAIBRCJ | Q | Wehrmacht Enigma I |\n| `'II'` | AJDKSIRUXBLHWTMCQGZNPYFVOE | E | Wehrmacht Enigma I |\n| `'III'` | BDFHJLCPRTXVZNYEIWGAKMUSQO | V | Wehrmacht Enigma I |\n| `'IV'` | ESOVPZJAYQUIRHXLNFTGKDCMWB | J | Kriegsmarine M3 |\n| `'V'` | VZBRGITYUPSDNHLXAWMJQOFECK | Z | Kriegsmarine M3 |\n| `'VI'` | JPGVOUMFYQBENHZRDKASXLICTW | Z \u0026 M | Kriegsmarine M4 |\n| `'VII'` | NZJHGRCXMYSWBOUFAIVLPEKQDT | Z \u0026 M | Kriegsmarine M4 |\n| `'VIII'` | FKQHTLXOCBJSPDZRAMEWNIUYGV | Z \u0026 M | Kriegsmarine M4 |\n| `'Beta'` | LEYJVCNIXWPBQMDRTAKZGFUHOS |  | Kriegsmarine M4, fourth rotor, didn't rotate, used with thin reflectors |\n| `'Gamma'` | FSOKANUERHMBTIYCWLQPZXVGJD |  | Kriegsmarine M4, fourth rotor, didn't rotate, used with thin reflectors |\n\nThe array expects 3 items (to simulate the Wehrmacht Enigma I or Kriegsmarine M3) or 4 items (for the Kriegsmarine M4). If the Enigma Machine is initialized with four rotors, it is assumed the left-most rotor is a Beta/Gamma rotor in an M4. Therefore the left-most rotor will not rotate.\n\nDefaults to `[III, II, I]`.\n\n**positions** Optional. An array of integers `[0..25]` which represent the positions of the rotors. Defaults to `[0, 0, 0]`.\n\n**ringSettings** Optional. An array of integers `[0..25]` which represent the ring settings (or Ringstellung) of the rotors. Defaults to `[0, 0, 0]`.\n\n**reflector** Optional. A string which represents the reflector type used. Available reflectors are:\n\n| Reflector | Encoding | Notes |\n| --- | --- | --- |\n| `'B'` | YRUHQSLDPXNGOKMIEBFZCWVJAT |  |\n| `'C'` | FVPJIAOYEDRZXWGCTKUQSBNMHL |  |\n| `'BThin'` | ENKQAUYWJICOPBLMDXZVFTHRGS | Kriegsmarine M4 |\n| `'BThin'` | RDOBJNTKVEHMLFCWZAXGYIPSUQ | Kriegsmarine M4 |\n\nDefaults to `'B'`.\n\n**plugboardPairs** Optional. A string containing a list of pairs of letters separated by spaces. This represents the letters that should be switched on the plugboard (or Steckerbrett). Defaults to an empty string (no substitutions).\n\n### EnigmaMachine.encodeString()\n\n#### Syntax\n\n```\nenigmaMachine.encodeString(text)\n```\n\n#### Output\n\nReturns a string which is the encoding/decoding of `text`.\n\n#### Parameters\n\n**text** The text to encode/decode. The text is required to only contain uppercase letters from the latin alphabet.\n\n## Learn More\n\nA good introduction to the Enigma Machine is this [Numberphile video](https://www.youtube.com/watch?v=G2_Q9FoD-oQ). You can find out more about the details of the inner workings of the machine on [Dirk Rijmenants' website](http://users.telenet.be/d.rijmenants/en/enigmatech.htm). One of the more complex quirks of the Enigma Machine's mechanism is the \"double step\". You can see this in action in [this video](https://www.youtube.com/watch?v=hcVhQeZ5gI4).\n\n## Contributors 🎉\n\n[mrpjevans](https://github.com/mrpjevans)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfogo%2Fenigma-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfogo%2Fenigma-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfogo%2Fenigma-simulator/lists"}