Encrypt & Save XOR Pickle to File
Persist Any Object to Disk, Password-Coded, From Your Graph
- obj
ComfyUI is terrible at remembering things between runs. Every workflow starts from scratch unless you re-enter every value. Save XOR Pickle To File is a way around that: it takes any object you can wire into it - a string, a dict of settings, a list, a nested structure - pickles it, compresses it, scrambles it with a password, and writes it to disk. Later, the pack's Load XOR Pickle From File node brings it back intact.
Think of it as the save-game for your workflow state. You can stash a whole configuration as a single object, reuse it across sessions, or hand a "save file" to someone else running the same workflow. The password part is mostly so the resulting .pkl isn't human-readable and doesn't load without intent - a mild convenience, and you should keep your expectations at that level.
How it works
The write path is the reverse of the read path, and it's refreshingly short:
pickle.dumps(obj)- serialize the object to bytes.zlib.compress- shrink it.- XOR-encrypt - derive a key by hashing your password with SHA-256 and repeating the hash to the data's length, then XOR every byte.
- Write to
folder_paths.get_output_directory() + filename.
Nothing else. No external dependencies beyond the standard library, no requirements.txt, no model downloads - rare for a custom node pack, and it means install is truly just a clone.
The encryption is the weak part, and you should know that going in. XOR with a single unsalted SHA-256 key is obfuscation, not encryption - a short password falls to a dictionary attack, and there's no authentication on the file. It's "keep casual snoopers out", not "protect a secret". The pickling itself is also worth remembering: pickle executes code on load, which is exactly why the ecosystem moved to safetensors for models. This node writes your own data, so that's fine - just never point the load node at a file you don't trust.
Inputs
Three inputs, all required, and honestly only two of them need your attention:
obj(ANY) - the thing you're saving. Any object from the graph.filename- where to write it. Defaults to"/content/file.pkl".password- used for encryption, must match exactly on load.
Change that filename default. "/content/file.pkl" is a leftover from the author's Google Colab workflow - on a normal install the node joins it onto your output directory, so you'd get something like output/content/file.pkl, which is nobody's idea of tidy. Set it to secret.pkl and it lands at ComfyUI/output/secret.pkl.
There are no outputs - this is an output node. It writes the file and prints [XORPickle] Salvato: <path> to your console so you can see exactly where it went.
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/iacoposk8/xor_pickle_nodes
Restart ComfyUI, and it'll show up under the "XOR Pickle" category. ComfyUI Manager users can search "xor_pickle_nodes" instead. There's nothing heavier to install.
Common issues
- The file isn't where you expect - remember the
output/prefix is automatic here, and yourfilenamedefault may still say/content/.... Change it to a plain name. - Load fails later with a zlib error - that's the matching load node telling you the password didn't match, or you pointed it at the wrong path. The format is custom to this pack, so nothing else will open these files anyway.
- A dict/object that won't pickle - some in-graph objects (lambdas, open file handles, some ComfyUI internals) can't be serialized. Stick to plain data: strings, numbers, lists, dicts.
Small pack, small scope, and it does the one job - persisting arbitrary objects - better than any text-only node can.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| obj | * | — | |
| filename | STRING | /content/file.pkl | — |
| password | STRING | — |
Outputs (0)
No outputs