Enigma

Category: Bletchley

Status: Registered and callable in the CyberChef 11.3.0 compatibility inventory.

Input / output: string → string

Background: https://wikipedia.org/wiki/Enigma_machine

What it does

Encipher/decipher with the WW2 Enigma machine. Enigma was used by the German military, among others, around the WW2 era as a portable cipher machine to protect sensitive military, diplomatic and commercial communications. The standard set of German military rotors and reflectors are provided. To configure the plugboard, enter a string of connected pairs of letters, e.g. AB CD EF connects A to B, C to D, and E to F. This is also used to create your own reflectors. To create your own rotor, enter the letters that the rotor maps A to Z to, in order, optionally followed by < then a list of stepping points. This is deliberately fairly permissive with rotor placements etc compared to a real Enigma (on which, for example, a four-rotor Enigma uses only the thin reflectors and the beta or gamma rotor in the 4th slot). More detailed descriptions of the Enigma, Typex and Bombe operations can be found here.

Note

Status here means the operation name is implemented and callable. It does not by itself promise byte-for-byte parity for every upstream option. See Compatibility and current status for the verified scope and known boundaries.

Arguments and options

Arguments are positional. Keep their order when using bake() or Pipeline.then().

Index

Name

UI type

PyChef default

Accepted values / format

0

Model

argSelector

'3-rotor'

'3-rotor', '4-rotor'

1

Left-most (4th) rotor

editableOption

'LEYJVCNIXWPBQMDRTAKZGFUHOS'

'LEYJVCNIXWPBQMDRTAKZGFUHOS', 'FSOKANUERHMBTIYCWLQPZXVGJD'

2

Left-most rotor ring setting

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

3

Left-most rotor initial value

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

4

Left-hand rotor

editableOption

'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R'

'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'AJDKSIRUXBLHWTMCQGZNPYFVOE<F', 'BDFHJLCPRTXVZNYEIWGAKMUSQO<W', 'ESOVPZJAYQUIRHXLNFTGKDCMWB<K', 'VZBRGITYUPSDNHLXAWMJQOFECK<A', 'JPGVOUMFYQBENHZRDKASXLICTW<AN', 'NZJHGRCXMYSWBOUFAIVLPEKQDT<AN', 'FKQHTLXOCBJSPDZRAMEWNIUYGV<AN'

5

Left-hand rotor ring setting

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

6

Left-hand rotor initial value

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

7

Middle rotor

editableOption

'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R'

'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'AJDKSIRUXBLHWTMCQGZNPYFVOE<F', 'BDFHJLCPRTXVZNYEIWGAKMUSQO<W', 'ESOVPZJAYQUIRHXLNFTGKDCMWB<K', 'VZBRGITYUPSDNHLXAWMJQOFECK<A', 'JPGVOUMFYQBENHZRDKASXLICTW<AN', 'NZJHGRCXMYSWBOUFAIVLPEKQDT<AN', 'FKQHTLXOCBJSPDZRAMEWNIUYGV<AN'

8

Middle rotor ring setting

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

9

Middle rotor initial value

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

10

Right-hand rotor

editableOption

'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R'

'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'AJDKSIRUXBLHWTMCQGZNPYFVOE<F', 'BDFHJLCPRTXVZNYEIWGAKMUSQO<W', 'ESOVPZJAYQUIRHXLNFTGKDCMWB<K', 'VZBRGITYUPSDNHLXAWMJQOFECK<A', 'JPGVOUMFYQBENHZRDKASXLICTW<AN', 'NZJHGRCXMYSWBOUFAIVLPEKQDT<AN', 'FKQHTLXOCBJSPDZRAMEWNIUYGV<AN'

11

Right-hand rotor ring setting

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

12

Right-hand rotor initial value

option

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

13

Reflector

editableOption

'AY BR CU DH EQ FS GL IP JX KN MO TZ VW'

'AY BR CU DH EQ FS GL IP JX KN MO TZ VW', 'AF BV CP DJ EI GO HY KR LZ MX NW TQ SU', 'AE BN CK DQ FU GY HW IJ LO MP RX SZ TV', 'AR BD CO EJ FN GT HK IV LM PW QZ SX UY'

14

Plugboard

string

''

''

15

Strict output

boolean

True

True or False

Recipe template

Important

This is a call template built from the documented defaults. Replace placeholder values such as empty keys, paths, patterns, or lookup data before running it.

from pychef import bake

input_value = "example"
args = ['3-rotor', 'LEYJVCNIXWPBQMDRTAKZGFUHOS', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'AY BR CU DH EQ FS GL IP JX KN MO TZ VW', '', True]
result = bake(input_value, [{"op": 'Enigma', "args": args}])
print(result)

Pipeline example

from pychef import Pipeline

args = ['3-rotor', 'LEYJVCNIXWPBQMDRTAKZGFUHOS', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'AY BR CU DH EQ FS GL IP JX KN MO TZ VW', '', True]
transform = Pipeline().then('Enigma', *args)
result = transform("example")

Dedicated operation module

The registered entry point lives in pychef.operations.by_operation.enigma. Direct calls receive the input value and a positional argument tuple:

from pychef.operations.by_operation.enigma import run

result = run("example", tuple(['3-rotor', 'LEYJVCNIXWPBQMDRTAKZGFUHOS', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'EKMFLGDQVZNTOWYHXUSPAIBRCJ<R', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'AY BR CU DH EQ FS GL IP JX KN MO TZ VW', '', True]))
pychef.operations.by_operation.enigma.run(value, args)

Run this operation using its shared internal implementation.

Parameters:
  • value (str | bytes)

  • args (Sequence[Any])

Return type:

str | bytes