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 |
|---|---|---|---|---|
|
Model |
|
|
|
|
Left-most (4th) rotor |
|
|
|
|
Left-most rotor ring setting |
|
|
|
|
Left-most rotor initial value |
|
|
|
|
Left-hand rotor |
|
|
|
|
Left-hand rotor ring setting |
|
|
|
|
Left-hand rotor initial value |
|
|
|
|
Middle rotor |
|
|
|
|
Middle rotor ring setting |
|
|
|
|
Middle rotor initial value |
|
|
|
|
Right-hand rotor |
|
|
|
|
Right-hand rotor ring setting |
|
|
|
|
Right-hand rotor initial value |
|
|
|
|
Reflector |
|
|
|
|
Plugboard |
|
|
|
|
Strict output |
|
|
|
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