Enigma simulator in Typescript
$ npm install enigma-machine
// CommunJS
const EnigmaMachine = require('enigma-machine');
// Browser
<script src="https://unpkg.com/enigma-machine@1.1.3/build/browser.js"></script>
const rotor1 = new EnigmaMachine.Rotor(/* RotorConfiguration Object */);
const reflector = new EnigmaMachine.Reflector(/* ConnectionMap Object */);
const plugboard = new EnigmaMachine.Plugboard(/* ConnectionMap Object */);
❓ See how to generate a random ConnectionMap
const enigma = new EnigmaMachine.Enigma([rotor1, rotor2, rotor3], reflector, plugboard);
const enigma = new EnigmaMachine.Enigma.generateFromEnigmaConfig(/* EnigmaConfiguration Object */);
const myMessage = enigma.calculateString('helloworld');
// Return 'lumquxgpzf' with a config that I lost :D
const mySecondMessage = enigma.calculateString('lumquxgpzf');
// Return 'helloworld' with the same config
See test file on GitHub
const rotorConfiguration = EnigmaMachine.generateRotorConfiguration();
RotorConfiguration
you can't use the generateConnectionMap
method !
// For a Reflector
const reflectorConnectionMap = EnigmaMachine.generateConnectionMap();
// const reflector = new EnigmaMachine.Reflector(reflectorConnectionMap);
// For a Plugboard
const plugboardConnectionMap = EnigmaMachine.generateConnectionMap();
// const plugboard = new EnigmaMachine.Plugboard(plugboardConnectionMap);
const enigmaConfig = EnigmaMachine.generateEnigmaConfiguration();
- Improve the browser version of the lib (because I'm bundling it manually) 🖥️
Nothing (I hope) 😀