Nodes/fexli-util-node-comfyui/FESaveEncryptImage
ComfyUI Node

FESaveEncryptImage

Save images that nobody else can open

By fexli·Created 3 years ago·Updated about a year ago· 3
FESaveEncryptImage
  • images
    filename_prefixCCUI
    password
    erase_pwd_in_metayes

    Most Save nodes write a PNG and move on. FESaveEncryptImage is the one you reach for when a plain PNG on disk is a problem - when the generated image shouldn't be viewable by anyone who finds the file. It writes your image, optionally encrypted with AES, using a password you supply, and it scrubs that password out of the embedded workflow metadata so your secret isn't just sitting in the PNG's tEXt chunk.

    The mechanism is the interesting part. It's real crypto, not security theater:

    • The image is rendered to PNG bytes (workflow metadata included, unless disabled).
    • A key is derived from your password via SHA-256.
    • The PNG bytes are encrypted with AES-CBC, with the IV derived from an MD5 hash of the PNG content itself.
    • The result is wrapped in a custom container - the bytes start with a literal EPNG magic header, followed by the ciphertext and the IV - and saved with an .epng extension.

    So you get a binary file with your image scrambled inside. The IV being a hash of the plaintext is a slightly unusual design choice, but for this use case it works: identical inputs produce identical ciphertext, which keeps things deterministic.

    Inputs that matter

    • images - the IMAGE tensor to save.
    • filename_prefix - the save prefix, default CCUI, same semantics as the stock save node.
    • password - the encryption key. Leave it empty and the node just saves a plain PNG - encryption is entirely optional.
    • erase_pwd_in_meta - yes (default) or no. When yes and a password is set, any occurrence of the password in the embedded prompt/extra_pnginfo metadata is replaced with ******** before writing. This is a thoughtful touch: without it, your password would be recoverable from the workflow metadata of the plain PNG saved inside the encrypted container.

    The big caveat

    There's no decrypt-in-ComfyUI node in this pack. FESaveEncryptImage is write-only from ComfyUI's perspective - the .epng files it produces have no stock loader here to bring them back into a graph. So think of it as an archive/export tool: you're locking images away (or shipping them somewhere) with a password, not building a round-trip pipeline. If you encrypt something, keep the password somewhere safe - lose it and the file is gone for good, which is, to be fair, kind of the point.

    Also worth noting: pycryptodome (the crypto library) is one of the two items in this pack's requirements.txt, and it's required for this node to import at all. If you see an import error mentioning Crypto, that's what's missing.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/fexli/fexli-util-node-comfyui
    cd fexli-util-node-comfyui
    pip install -r requirements.txt   # installs pycryptodome + sseclient-py
    

    Or ComfyUI Manager → search fexli-util-node-comfyui → install → restart. Restart after installing so the Crypto import resolves.

    It's a niche node, and it's the sort of thing most users never need - but when you need "this output must not be readable by whoever finds the file," it does the job with real encryption and a metadata-scrubbing touch most similar tools skip.

    Categoryfexli/image

    Inputs (4)

    NameTypeDefaultDescription
    imagesIMAGE
    filename_prefixSTRINGCCUI
    passwordSTRING
    erase_pwd_in_metaCOMBOyes2 options: yes, no

    Outputs (0)

    No outputs