Nodes/ComfyUI ARG Toolkit/Bitwise OR Operator
ComfyUI Node

Bitwise OR Operator

Combine two strings bit-by-bit with the OR operator

By AzelusLightvale·Created 12 months ago·Updated 5 days ago· 1
Bitwise OR Operator
    • bitwise_txt
    text_1Hello World!
    text_2Hello World!
    datatypeBinary
    encoding_format
    other_encoding_format

    The Bitwise OR Operator takes two strings and produces a third where every byte is the logical OR of the two inputs: a bit is 1 if either input has a 1 there. In ARG and stego work that's less glamorous than XOR - it's not reversible, so it's not much use as a cipher primitive - but it's exactly what you need when a puzzle asks you to merge two layers of flags, overlay a bitmask, or combine a "header" value with per-byte "modifiers." Think of it as a crude image-mask operation, but on bytes.

    The honest framing: OR is the operator you use when you want information to stick. Where XOR needs the same key on both sides to undo, OR is a one-way merge - the output is 1 wherever either input was 1, and you can't recover the original from the result. If your puzzle expects a reversible operation, you probably want the sibling BitwiseXOR node instead. If it expects bits to get set and stay set, this is the one.

    How it works

    Feed in two strings, and the node converts both to raw bytes using the datatype you pick, then walks them byte-by-byte applying x | y, and formats the result back into the same datatype. Two things to know before you wire anything up:

    1. Lengths must match. The node raises a ValueError ("Inputs must be same length for bitwise operations") if text_1 and text_2 decode to different byte counts. "Hello" vs "World!" is a difference of one byte and it will refuse. Pad or trim to equal length first.
    2. It operates on bytes, not characters. Pick your datatype to match the problem. Hexadecimal and Binary are the sane choices for raw data; String means the bytes are UTF-8 and the output gets decoded back into text, which can blow up if the OR result isn't valid UTF-8.

    The inputs that matter

    • text_1 - the main string (the tooltip calls it "the main string to compare against").
    • text_2 - the secondary string. Same datatype requirement.
    • datatype - interpretation of both inputs and the output: String, Hexadecimal, Base64, Integer, Binary.
    • encoding_format - text encoding used only when datatype is String; defaults around utf-8, with an Other option backed by other_encoding_format for custom codecs.

    Output is a single bitwise_txt string in the same format as the inputs.

    Installing it

    Part of the ComfyUI ARG Toolkit pack, so you get this node the moment you install the pack. In ComfyUI Manager, search "ComfyUI ARG Toolkit" and install; or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
    

    Restart ComfyUI afterward. The pack's dependency list is heavier than its niche suggests - invisible-watermark drags in torch and opencv-python - so give the first install a minute. No models, no API keys, all local.

    Gotchas

    The same-length rule is the #1 trip-up, and it's easy to hit when both default values are "Hello World!" but you change one of them. Also keep the one-way nature in mind: OR never removes a bit that's already set, so it's a terrible choice for "undo" operations and a great choice for building a composite byte out of flag layers. If you're mid-puzzle and the output looks longer or wrong, double-check that both inputs actually decoded to equal-length byte strings rather than equal-looking text.

    CategoryARG Toolkit/Utilities/Bitwise

    Inputs (5)

    NameTypeDefaultDescription
    text_1STRINGHello World!The main string to compare against. Accepts format defined in `datatype`
    text_2STRINGHello World!The secondary string to compare against. Accepts format defined in `datatype`
    datatypeCOMBOBinaryThe 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_formatCOMBOThe encoding format available for text, may yield different results when converting.
    other_encoding_formatoptSTRINGIf, 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)

    NameTypeDescription
    bitwise_txtSTRING