@janbican/enigma
v1.0.1
Published
Emulates Enigma machine encrypting/decrypting
Downloads
2
Maintainers
Readme
About
Library emulating Enigma machine encryption/decryption in Javascript.
It is used for encrypting and decrypting messages.
Configuration:
- rotors: I, II, III, IV, V
- reflectors: B, C
- plugboard: up to 13 pairs of letters
- rotor offsets
- rotor ring settings
Install
npm install @janbican/enigma
Usage
Default Enigma (rotors: I, II, III, reflector: B, offsets: 'AAA', ringSetings: 'AAA', pairs: [])
const { Enigma, rotors, reflectors } = require('@janbican/enigma')
const enigma = new Enigma()
const cipher = enigma.convertText('HELLOWORLD')
console.log(cipher)
// ILBDAAMTAZ
Enigma with custome settings
const { Enigma, rotors, reflectors } = require('@janbican/enigma')
const enigma = new Enigma({
left: rotors.IV, middle: rotors.V, right: rotors.I,
reflector: reflectors.C,
offsets: 'ZTF', ringSettings: 'FDC',
pairs: ['TF', 'GJ', 'AP', 'MC']
})
const cipher = enigma.convertText('HELLOWORLD')
console.log(cipher)
// CXCIIRIOGA
API specification in lib/enigma.js
Notes
- valid alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- convertText(text) normalizes text (deletes spaces, interpunction, diacritics)