ComfyUI Node

Bifid Cipher

Fractionation Without a Key Word (Just a Number)

By AzelusLightvale·Created 12 months ago·Updated 4 days ago· 1
Bifid Cipher
    • encrypted_txt
    textHello World!
    alphabetENGLISH
    modetrue
    keep_formattingtrue
    key10

    Bifid is the fractionating cipher that predates and inspires the ADFGX family, invented by the same French cryptographer, Félix Delastelle, in 1901. The core idea: every letter is a coordinate in a Polybius square, so a message becomes two lists of digits (one for rows, one for columns). Bifid's twist is that it fractionates - it concatenates those two lists and reads them back in pairs, so the row and column digits get scrambled together before being turned back into letters. The result is a cipher where the same letter can encrypt to different outputs depending on context, and frequency analysis gets a much harder job than with a plain monoalphabetic substitution.

    The one thing that makes Bifid different from nearly everything else in the pack: its key is an integer, not a word. The key input defaults to 10 and the tooltip asks for any non-negative integer. That number is the period - how many letters get fractionated together at a time. A period of 1 is trivially weak (it degenerates toward a plain substitution), and larger periods produce stronger mixing at the cost of making the ciphertext longer to hand-decode. If you want the historical default, period 5 is the classic recommendation.

    The inputs that matter

    • key (INT) - the period, default 10. This is the entire security story of the node. Pick a sensible value (5 is the textbook one; 10 is fine too) and write it down - decrypt needs the exact same number.
    • mode - encrypt/decrypt toggle (on = encrypt).
    • text, alphabet, keep_formatting - the standard classical kit, alphabet defaulting to ENGLISH.

    Output is the usual single encrypted_txt STRING.

    Where people get burned

    The integer-key surprise hits everyone once. You reach for "the Bifid cipher," see an INT field, and briefly wonder if you grabbed the wrong node - you didn't, Bifid is period-keyed. The second trap is changing the key between encrypt and decrypt; because the period reshapes the whole digit stream, any difference produces instant garbage with no error. Third: the pack's preprocessing lowercases and strips your message before encrypting, which matters if you're cross-checking against an online Bifid tool - make sure keep_formatting matches on both sides, and keep in mind that implementations differ on whether they pad odd-length groups.

    One honesty note: Bifid with a small period is vulnerable to a known-plaintext-style attack, and a knowledgeable solver can crack it by hand given enough ciphertext. It's a great mid-tier puzzle, not a secret-keeper.

    Installing it

    Standard ARG Toolkit install:

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

    Restart ComfyUI and it's under ARG Toolkit → Cryptography → Classical (or ComfyUI Manager → search "ComfyUI ARG Toolkit"). Classical ciphers use secretpy, installed by Manager or via pip install -r requirements.txt on manual clones. Pure Python, no models.

    Troubleshooting

    • Decrypt is garbage → period key mismatch, or you changed key between passes.
    • "This should take a keyword" → no; Bifid takes an integer period. That's the design.
    • Reference tool disagrees → match keep_formatting and confirm the tool uses the same period and alphabet.

    Bifid is the cipher that teaches you what "fractionation" actually means, and its period knob is a rare thing in a puzzle cipher: a difficulty dial you can turn yourself.

    CategoryARG Toolkit/Cryptography/Classical

    Inputs (5)

    NameTypeDefaultDescription
    textSTRINGHello World!
    alphabetSTRINGENGLISHInput your alphabet here. If left blank, uses the alphabet default to the cipher. Uses standard connected format ('abcdef'), but can also accept the alphabets defined in secretpy in alphabets.py.
    modeBOOLEANtrueToggle between encrypting or decrypting a message.
    keep_formattingBOOLEANtrueToggle between preserving the format of the message or remove all spaces, punctuations, and convert to lowercase.
    keyINT10Accepts any non-negative integer as the key to decrypt/encrypt.

    Outputs (1)

    NameTypeDescription
    encrypted_txtSTRING