enigma-ts
v0.0.3
Published
TypeScript Enigma Machine Implementation
Downloads
5
Maintainers
Readme
Enigma
TypeScript Enigma Machine Implementation.
Enigma M3 with three rotors, reflector and plugboard.
Work principle can be found here
Install
npm i enigma-ts
Usage
var Enigma = require('enigma-ts');
var enigma = new Enigma('AAA');
enigma.process('HELLO WORLD'); // LMHNH TMAUA
/**
* Or with configuration
* */
var default_config = {
rotors: [
{'EKMFLGDQVZNTOWYHXUSPAIBRCJ': 'Q'},
{'AJDKSIRUXBLHWTMCQGZNPYFVOE': 'E'},
{'BDFHJLCPRTXVZNYEIWGAKMUSQO': 'V'},
],
plugboard: ['AY', 'BR', 'CU', 'DH', 'EQ', 'FS', 'GL', 'IP', 'JX', 'KN', 'MO', 'TZ', 'VW'],
reflector: 'YRUHQSLDPXNGOKMIEBFZCWVJAT',
};
enigma = new Enigma('OBY', default_config);
enigma.positions; // OBY
enigma.positions = 'AAA';
enigma.positions; // AAA
Test
npm i
npm test