@janbican/enigma

1.0.1 • Public • Published

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

More about Enigma

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)

Package Sidebar

Install

npm i @janbican/enigma

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

29.2 kB

Total Files

13

Last publish

Collaborators

  • janbican