Options
All
  • Public
  • Public/Protected
  • All
Menu

Enigma String Cypher

DO NOT USE THIS FOR PASSWORDs

Used to Encode Strings that can be decoded later with another exactly configured Enigma Instance.

This is useful for encoding sensitive information in a database that can be decoded later on by the application.

More About The Enigma Machine

Hierarchy

  • Enigma

Index

Constructors

  • new Enigma(diskConfiguration?: string): Enigma
  • Build an Enigma Instance

    example

    const enigma = new Enigma("A12,E43,B27,FC,cS,yW,kA,iJ");

    Parameters

    • diskConfiguration: string = ""

      Pass in an initial configuration

    Returns Enigma

    a configured Enigma Instance

Properties

availableDisks: EnigmaAvailableDisks = ...

Static Disks Setup by the System

currentDisks: string[] = ...

Current Configured Disks

currentIndex: number[] = ...

Current Configured Index for the Disks

currentWireMap: EnigmaDisk = {}

Current Wire Map Configuration

diskLength: number = ...

The Length of the Disk Keys in the System - Used in this.manageOffset rollover

setup: string = "A12,E43,B27,FC,cS,yW,kA,iJ"

Base Setup of the Enigma Encoder

transitionalDisks: EnigmaAvailableDisks = {}

Transitional Disks Setup by the System

These Disk Handle the letter changing between 2 disks and uses a key of [Disk1][Disk2][OffsetRotation: int]

Methods

  • betweenDisks(disk1: string, disk2: string, passedOffset: number, letter: string): string
  • Passes a Letter Between two configured Enigma Drums

    example

    const translated = new Enigma().betweenDisks("A", "B", 4, "X");

    Parameters

    • disk1: string

      The Disk the Letter is being passed from

    • disk2: string

      The Disk the Letter is being passed to

    • passedOffset: number

      The Index Offset

    • letter: string

      The Character Being Changed

    Returns string

    the encrypted Character

  • buildDiskKey(disk1: string, disk2: string, offset: number): string
  • Builds the Disk Key used for Transitional Disks

    Parameters

    • disk1: string

      The Disk the Letter is being passed from

    • disk2: string

      The Disk the Letter is being passed to

    • offset: number

      The Index Offset

    Returns string

    a Key used for this.transitionalDisks

  • buildTransitionalDisk(disk1: string, disk2: string, offset: number): void
  • Builds a Transitional Disk in the Instance as Required

    Parameters

    • disk1: string

      The Disk the Letter is being passed from

    • disk2: string

      The Disk the Letter is being passed to

    • offset: number

      The Index Offset

    Returns void

    a Key used for this.transitionalDisks

  • configure(value: string): Enigma
  • Manually Reconfigure this instance of Enigma

    example

    new Enigma().configure("A12,E43,B27,FC,cS,yW,kA,iJ");

    Parameters

    • value: string

    Returns Enigma

    this

  • decode(value: string): string
  • Decode a UTF8 value

    example

    const translated = new Enigma().decode("Hello World");

    Parameters

    • value: string

      the value to be decoded

    Returns string

    the decoded ASCII string

  • encode(value: string): string
  • Encode an ASCII string

    example

    const translated = new Enigma().encode("Hello World");

    Parameters

    • value: string

      The value to be encoded

    Returns string

    the encoded UTF8 value

  • manageOffset(value: number): number
  • Ensure that the provided index gets wrapped to 0 + offset when over allowed length

    example

    const offset = new Enigma().manageOffset(149);

    Parameters

    • value: number

    Returns number

    a wrapped index

  • Reset this instance of Enigma to its configuration

    example

    new Enigma().reset();

    Returns Enigma

    this

  • throughDisk(disk: string, letter: string): string
  • Passes a Letter through a configured Enigma Drum

    example

    const translated = new Enigma().throughDisk("A", "X");

    Parameters

    • disk: string

      The Disk the Letter is being passed through

    • letter: string

      The Character Being Changed

    Returns string

    the encrypted Character

  • throughWireBoard(letter: string): string
  • Passes a Letter through the manually configured Wire Map

    example

    const translated = new Enigma().throughWireBoard("A");

    Parameters

    • letter: string

      The letter to translate

    Returns string

    The translated letter

  • translate(value: string): string
  • Translates a String by passing it through the configured set of Enigma Drums

    example

    const translated = new Enigma().translate("Hello World");

    Parameters

    • value: string

      The String be passed converted

    Returns string

    the result of the string after its passed through the drums

Generated using TypeDoc