Go Reference GitHub

Enigma

Terminal Enigma machine simulator

Installation

$ go install github.com/lusingander/enigma/cmd/[email protected]

(require Go 1.18+)

Usage

Keybindings

Key Description
AZ input
Ctrl+c quit
Esc reset

Using as a library

import "github.com/lusingander/enigma/enigma"

func main() {
    e := enigma.NewM3(
        [3]enigma.Rotor{
            enigma.NewRotor1('A', 'A'), // (initial position, ring setting)
            enigma.NewRotor2('A', 'A'),
            enigma.NewRotor3('A', 'A'),
        },
        enigma.NewReflectorB(),
        enigma.NewPlugboard(),
    )

    e.EncodeString("HELLO") // returns "MFNCZ"
    e.EncodeString("HELLO") // returns "RHOZF"
}

License

MIT

GitHub

View Github