GithubHelp home page GithubHelp logo

matheusportela / enigma-machine Goto Github PK

View Code? Open in Web Editor NEW
33.0 33.0 10.0 43 KB

Enigma machine simulator in JavaScript for didactic purposes.

License: MIT License

JavaScript 63.73% HTML 33.76% CSS 2.51%

enigma-machine's People

Contributors

matheusportela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

enigma-machine's Issues

Rotor `EZI` issue

Hello,

Using the dcode to verify with rotor types III, II, I, ground settings A, E, W and ring setting A, A, A, I input AAA and the output is EZI while the expected output is IBM.

Using ground setting A, D, V, when inputting AAAA the output is QEZI while the expected output is QIBM.

Apply rotor step before executing encoding

Extracted from Technical Details on the Enigma Machine

Remember that, when depressing a key, the rotors advance before the electrical signal runs through the rotors. Therefore, to examine the current flow through the rightmost rotor in A position, the rotor must be set in the Z position before depressing the key (this also counts for the other rotors if they are due to step). In the examples above, no plugs are set on the plugboard and the signal runs directly from the A key, through the entry rotor, to rotor I.

Currently, stepping is applied after running the letter encoding

Create assertions to avoid errors

Issue #6 was due to a mistakenly configured plugboard. Should I had done some assertions, such as checking whether each plugboard configuration has exactly two letters, this would have been avoided.

Implement double-stepping in middle rotor

Extracted from Technical Details on the Enigma Machine:

The rotors appear to work as a normal odometer, with the right-most rotor always stepping on each key stroke and the other rotors stepping after a complete cycle of the previous rotor, but there is an important difference due to the system of pawls and teeth. The middle rotor will advance on the next step of the first rotor a second time in a row, if the middle rotor is in its own turnover position. This is called the double-step. Below and example of such a sequence when the rotors III – II - I are used:

KDO KDP, KDQ, KER, LFS, LFT, LFU…

As you can observe, stepping from Q to R advances the middle rotor, and on the next step that middle rotor steps again, advancing the third rotor also. This is caused by the mechanical design of pawls and ratchets. There are three pawls that are all three activated on every key stroke. Each pawl is half positioned on the index ring (carrying a notch) of the rotor on its right, and half positioned above the 26 teeth of the rotor on its left (viewed from the point of the operator). A rotor’s ring prevents the pawl from pushing into the teeth of the next-left rotor. When a notch occurs in a ring, the pawl can drop into that notch and push into the teeth of the next-left rotor. Since the right-most pawl is not above an index ring it will continuously advance the right-most rotor.

Once the right-most rotor has stepped and the middle (spring-loaded) pawl can drop down in the right rotor's notch, it will engage the middle rotor's teeth, pushing the middle rotor one step. An identical event will take place when the middle rotor's notch enables the third pawl to drive the teeth of the left-most rotor. A rotor will not only advance if its teeth are catched, but also when a pawl pushes into its notch. This situation creates a double-step of the middle rotor: the right rotor steps and the middle pawl takes the middle rotor one step further. If the middle rotor has moved by this step into its own notch position, then, on the next step, the left-most pawl catches the teeth of the left-most rotor, but the same pawl also pushes in the middle rotor's notch, moving it a second time in a row. Note that a double notched rotor in the middle position will also have two double steps.

Implement rotor settings

Quoting http://enigma.louisedade.co.uk/howitworks.html:

There are five possible rotors that can be used in any order for the three rotor positions: right, middle, left. Each rotor has an inner ring of contacts and an outer ring of contacts and their purpose is to scramble the signal. The outer ring contacts connect each rotor to the next rotor (or the static rotor / reflector) as well as its own inner ring. The inner ring contacts can be rotated relative to the outer ring which results in even more possible connections (and therefore, letter substitutions). The whole rotor itself can be rotated relative to the static rotor, so that the static rotor 'A' output is not connected to 'A' input on the rotating rotor.

Currently, the rotors don't have a configurable inner ring to allow scrambling even further the input/output rings. We can consider it as if the inner setting was fixed, i.e., the output A is always considered to be connected to the A position of its inner ring.

The simulator at http://enigma.louisedade.co.uk/enigma.html can be used to provide output messages for testing purposes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.