Nodes/ComfyUI ARG Toolkit/Beaufort Cipher
ComfyUI Node

Beaufort Cipher

Vigenère's Symmetric Cousin (Same Key, Either Direction)

By AzelusLightvale·Created 12 months ago·Updated 5 days ago· 1
Beaufort Cipher
    • encrypted_txt
    textHello World!
    alphabetENGLISH
    modetrue
    keep_formattingtrue
    key

    Beaufort is what you get when you take Vigenère and flip the subtraction around. Instead of cipher = plaintext + key, it computes cipher = key - plaintext. It's named after Sir Francis Beaufort (yes, the wind-scale guy - he had a varied career), and while it looks nearly identical to Vigenère, that one sign flip gives it a lovely property: encrypting and decrypting are the same operation. Run Beaufort encryption twice and you're back to your original text. That's a genuinely useful trait for a puzzle cipher, because it means a solver who figures out the decryption is literally just running the cipher again - and it's the trait that keeps Beaufort from being a mere curiosity.

    The node itself is the pack's standard classical-cipher shape: text, alphabet, mode, and keep_formatting plus a key string (any text in the alphabet's language, empty by default). The mode toggle is still there for interface consistency, but as with Atbash, the math makes it nearly redundant - the key is what matters, not the direction. Output is the single encrypted_txt STRING.

    The inputs that matter

    • key - the keyword. With Beaufort, the same key encrypts and decrypts, which is one less thing to get wrong in a workflow. Just don't lose it.
    • mode - present, harmless, mostly decorative. Flip it if you like; the result won't change.
    • keep_formatting - the pack's spaces/punctuation/case toggle, worth remembering when comparing against reference tools.

    Where people get burned

    The main trap is expecting Beaufort to behave like Vigenère and assuming decryption needs a "reversed" key or mode. It doesn't. The second, more practical trap is key handling: the pack lowercases string keys in shared preprocessing, so if your reference tool is case-sensitive about the key, match its convention or you'll get output that "should" match but doesn't. And like every polyalphabetic cipher here, the round-trip is all-or-nothing - one character off in the key and decryption is instant garbage, no error message, no mercy.

    Worth knowing before you build a puzzle around it: Beaufort is still a classical polyalphabetic substitution, so it's crackable with frequency analysis and known-plaintext work once the solver has enough ciphertext. It's a step up from Vigenère's repeating-key weakness only in the sense that it's less commonly attacked - not because it's fundamentally stronger. Use it for a satisfying mid-tier clue, not for anything that must stay secret.

    Installing it

    Standard pack install:

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

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

    Troubleshooting

    • Decrypt fails → key mismatch. Beaufort won't tell you nicely.
    • Mode doesn't seem to do anything → correct, that's the symmetric property working as intended.
    • Differs from an online tool → check formatting toggles and key case conventions.

    Beaufort is the cipher for constructors who like elegant properties - the same key both ways is a neat detail to build a clue around ("the key unlocks both doors"). In a pack full of field ciphers and polyalphabetic classics, it's a quietly clever choice.

    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.
    keySTRINGAccepts any text in the alphabet's language as the key to decrypt/encrypt.

    Outputs (1)

    NameTypeDescription
    encrypted_txtSTRING