Nodes/ComfyUI-BlindWatermark/Encrypt/Decrypt Image
ComfyUI Node

Encrypt/Decrypt Image

Encrypt/Decrypt Image — It Scrambles Pixels, Not Secrets

By lihaoyun6·Created about a year ago·Updated 12 months ago· 18
Encrypt/Decrypt Image
  • image
  • IMAGE
modeencrypt
password

The odd one out in this pack. Apply/Decode Blind Watermark are about hiding a mark inside an image that still looks normal; this node makes the whole image look like static and lets you restore it later with a 4-digit password. Fun, fast, reversible - and despite the name, not encryption in the cryptographic sense. It's pixel scrambling, which matters a lot for what you should use it for.

It ships in ComfyUI-BlindWatermark by lihaoyun6, alongside the watermark nodes. Same install, same dependency list, no models, no GPU.

How it works

Under the hood it walks the pixels along a space-filling curve (a Numba-optimized Hilbert/Gilbert curve) and permutes their positions using a pseudo-random offset based on the golden ratio, then applies that permutation some number of times. The "password" controls three things: the first two digits are the number of permutation rounds, the third digit is vertical padding, and the fourth is horizontal padding. The padding is the clever bit - it duplicates border rows and columns so that after permutation there's a frame around the scrambled data, and decryption simply crops that frame off and runs the permutation in reverse. The result is lossless: encrypt then decrypt with the same password and you get the original back, RGBA intact.

A password must be exactly four digits or the node raises a ValueError. Leave the field empty and it quietly uses "0000" - so empty-password users are all using the same key. Don't do that.

The inputs

  • image - anything; each image in a batch is processed separately.
  • mode - encrypt or decrypt. Encrypting an already-encrypted image keeps scrambling it; decrypting anything that wasn't encrypted gives you garbage back with no error.
  • password - 4-digit numeric string. Same one on both ends, obviously.

Output is a single image tensor. Unlike the watermark nodes, this one is not an output node, so you wire it into Save Image (or anything else) yourself.

The honest limits

Calling this "encryption" oversells it. The pixels are rearranged, not obfuscated by value - the image data is all still there in plain sight, just in the wrong order. More importantly, a 4-digit password has 10,000 combinations, and the scheme is open source. Anyone who knows the method can brute-force it in under a minute. So treat this as a way to hide an image from casual viewers - someone scrolling a folder, a shared screen, a preview thumbnail - not as a way to protect a secret from anyone who wants it.

What it is genuinely good at: making an image unreadable at a glance while staying fully recoverable, all on CPU, with zero dependencies beyond the pack's normal ones. If you want to tuck a workflow's reference image away, pass an image through it and save the scrambled version with the password written down. Just keep expectations in the right place - it's a lock on a locker, not a safe.

Installing

The standard pack install: ComfyUI Manager → search "ComfyUI-BlindWatermark", or:

cd ComfyUI/custom_nodes
git clone https://github.com/lihaoyun6/ComfyUI-BlindWatermark
cd ComfyUI-BlindWatermark
pip install -r requirements.txt

Restart ComfyUI. Dependencies are pillow, opencv-python, numpy, pywavelets, numba. The numba JIT compile means the first encrypt/decrypt can take a few extra seconds - after that it's quick. Remember the password; unlike the seed on the watermark nodes there's no "recoverable" version, but there's also nothing secure enough to need one.

Categoryimage

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
modeCOMBOencrypt2 options: encrypt, decrypt
passwordSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE