Rotor Machine Encrypt/Decrypt
Where the cipher actually happens — and where your punctuation goes to die
- machine
- positions
- encrypted_msg
- rotor_pos
Every other node in the rotor category feeds this one. Machine assembled, positions set, stepping rules chosen - then you paste text in and this node runs each character through the signal path, stepping the wheels as it goes. Two outputs: encrypted_msg (a plain STRING) and rotor_pos (where the wheels ended up).
It's also the node that teaches you why real operators worked in five-letter groups with no punctuation.
The inputs
machine and positions are MACHINE and POSITIONS objects from the assembly and positions nodes - both forced to sockets so you can't accidentally leave them as widgets. text is a multiline string; your message lives here.
mode decides direction. Off is Encrypt (the default), on is Decrypt.
preserve is the one that surprises people. With it off - the default - every character that isn't in the machine's alphabet is silently dropped. Not rejected, not replaced, dropped. Type Hello, World! into a default A–Z machine and the space, comma and exclamation simply vanish; the output is 10 letters because only 10 characters were ever encipherable. Turn preserve on and non-alphabet characters pass through untouched, and lowercase input letters come back lowercase, so Hello, World! keeps its shape and its casing.
That's genuinely useful when you're hiding a message inside readable text - the punctuation is camouflage. It's a trap when you're trying to encrypt a sentence you expect to decrypt back to exactly what you typed, and a stray comma silently changes nothing while a stray letter silently changes everything downstream.
One hard rule: alphabets must be uncased. If a rotor's alphabet contains lowercase characters, the node throws alphabets must be uppercase/uncased: input is case-folded. Build machines in uppercase, and let preserve handle the cosmetics.
What happens per character
Mechanically, each character is converted to an index in the input alphabet, the wheels step first, then the index walks the path - plugboard, entry wheel, rotors right-to-left, reflector, and back through the inverted stages. Stepping before enciphering is what real machines do and it matters: it's why your very first letter is never enciphered in the position you set. If you set AAA and expect the first keystroke to behave like a static substitution at AAA, it won't. It behaves like AAB.
Decrypt runs the same path inverted, in reverse order. For a machine with a reflector this is nearly free: reflection makes the cipher its own inverse, so Encrypt and Decrypt give identical results on the same settings, and you can "decrypt" by re-encrypting. Historical Enigma traffic worked exactly that way. For a machine without a reflector - which the pack fully allows, since reflector and reflector_rotor are both optional - the cipher is not reciprocal, and you genuinely need to flip mode to Decrypt. The descriptor node will tell you which situation you're in with the line "path has no repeated stages: likely non-reflecting, so decrypt mode is required". Heed it.
Reading the output
encrypted_msg is a string, and this node isn't an output node, so you need something to look at it. ComfyUI's own preview-as-string handles that now; the pack's README also recommends ComfyUI-Custom-Scripts, whose Show Text node used to be the only way and is still the better viewer for long messages.
rotor_pos is the machine state after the last character. Wire it into another encrypt node's positions and you can run a long message in segments as if it were one. That's also how you verify a decryption round trip: encrypt, keep the start and end positions, then decrypt from the start and check you land on the same end state. If the states match but the text doesn't, your alphabets are fine and your preserve setting isn't.
Installing it
Manager → search ComfyUI ARG Toolkit → install → restart → refresh the browser. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
pip install -r requirements.txt
Pure Python on the code path, but the pack's requirements file is the whole spread - torch==2.14.1, torchaudio, cryptography, stegano, invisible-watermark. Letting pip resolve that against a working ComfyUI venv can cost you a CUDA build. Manager doesn't isolate anything either; it just installs the same pins more conveniently.
A calibration worth doing once
Build the canonical setup - three default rotors, Enigma reflector B, preset stepper Enigma, positions AAA - and encrypt AAAAA. You should get five different letters. Five identical letters means the wheels aren't stepping; check the stepper, not the machine. Then flip mode to Decrypt and feed the output back: with a reflector you get AAAAA again, and you've just demonstrated the property that made this machine both practical and breakable. Small win, but you'll trust the rest of the pack a lot more afterwards.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| machine | MACHINE | — | |
| positions | POSITIONS | — | |
| text | STRING | Hello World! | — |
| preserve | BOOLEAN | false | When set to true, attempt to preserve the form of the message, including case and punctuation marks. |
| mode | BOOLEAN | false | Whether to encrypt or decrypt the message. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| encrypted_msg | STRING | — |
| rotor_pos | POSITIONS | — |