Bitwise XOR Operator
The reversible operator that shows up everywhere in ARGs
- bitwise_txt
If you only ever use one node from the ARG Toolkit's bitwise family, make it this one. Bitwise XOR takes two strings and flips each bit where the inputs differ - 1 XOR 1 = 0, 1 XOR 0 = 1. That single property, reversibility, makes it the workhorse of light cryptography and puzzle design: XOR the message with a key and you get ciphertext; XOR the ciphertext with the same key and the message comes right back. It's how one-time-pad schemes work, it's how a huge chunk of historical ciphers get bolted together, and it's the answer to roughly half the "why does this look like random noise" questions in ARG solving.
The classic trick is the self-check: A XOR A = 0 and A XOR B XOR B = A. If a puzzle hands you two strings and says "combine them," and you're not sure whether it means XOR - try it. There's no guessing about whether you did it right, because running the same two inputs through again inverts the operation. That's more than OR and AND can claim, and it's why XOR is the operator you'd actually wire into a real workflow rather than just tinker with.
How it works
The node decodes both text_1 and text_2 into raw bytes using the datatype you choose, applies x ^ y byte-by-byte, and re-encodes the result into that same format. Two operational rules you'll hit quickly:
- Lengths must match.
text_1andtext_2have to decode to the same number of bytes or the node throwsValueError: Inputs must be same length for bitwise operations. For a key XOR that's natural - you XOR against a key of equal length - but "Hello" vs "World!" will refuse, so pad or trim. - It works on bytes, not text. Pick
HexadecimalorBinarydatatype for raw data. If you insist onString, the node XORs UTF-8 bytes and tries to decode the result - valid XOR output isn't guaranteed valid UTF-8, and you'll get aUnicodeDecodeErrorwhen it isn't.
The inputs that matter
text_1- the message (or the "main string to compare against," per the tooltip).text_2- the key / second operand. Same length requirement, same datatype.datatype- interpretation of both inputs and the output:String,Hexadecimal,Base64,Integer,Binary.encoding_format- only relevant forStringdatatype;Other+other_encoding_formatfor custom codecs.
Output is a single bitwise_txt string in the input's format.
Installing it
Ships in the ComfyUI ARG Toolkit pack. Install via ComfyUI Manager (search "ComfyUI ARG Toolkit") or:
cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
Restart ComfyUI. Dependency install is the slow part - the pack pulls cryptography, secretpy, stegano, invisible-watermark, reedsolo, and transitively torch plus opencv-python. No models, no keys, fully local.
Gotchas
The equal-length requirement is where people lose minutes. And a genuinely useful ARG habit: if you suspect a string was XOR'd with a repeated key, XOR it against a repeated guess of the key's first byte and look for legible text - this node makes that brute-force loop trivial if you're willing to chain a few of them. Just remember the output format follows the input datatype, and string-datatype XOR output will often refuse to decode.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| text_1 | STRING | Hello World! | The main string to compare against. Accepts format defined in `datatype` |
| text_2 | STRING | Hello World! | The secondary string to compare against. Accepts format defined in `datatype` |
| datatype | COMBO | Binary | The datatype that the two texts is assumed to be for comparison purpose. Will also output the final output based on the chosen datatype as well. |
| encoding_format | COMBO | The encoding format available for text, may yield different results when converting. | |
| other_encoding_formatopt | STRING | If, for some reason, your chosen encoding format is not available in the dropdown, select "Other" in encoding_format and type in your encoding format here. Supports all format written in Python's `encoding` module. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| bitwise_txt | STRING | — |