Symmetrical Padding
Pad your block-cipher data to the right size (and unpad it back)
- padding_data
- padded_data
Block ciphers like AES work on fixed-size blocks - 128 bits, typically. Your message almost never fits neatly into a multiple of that, which is why you need padding: extra bytes added to the end so the last block is full. The Padding node (display name "Symmetrical Padding") does that and its inverse, unpadding, and it's one of those boring-in-isolation nodes that becomes essential the moment you start using the pack's modern encryption nodes. If you're doing real cryptography in ComfyUI, you can't get far without it.
The inputs are small and to the point:
- padding_data - the bytes to pad or unpad (BYTESLIKE, so feed it bytes, not a string).
- block_size - the block size in bits, default 128. That's the trap: 128 here means 16 bytes. If you're padding for AES-128, leave it at 128.
- algorithm -
PKCS7orANSIX923. PKCS7 is the default and the one you'll use 99% of the time; it pads with bytes equal to the number of padding bytes added. ANSIX923 is a legacy alternative that zero-fills and puts the pad length in the last byte. - mode - pad or unpad.
The output, padded_data, is BYTESLIKE again - the padded (or unpadded) result, ready to feed into an encryption node.
Mechanically it's a thin wrapper over Python's cryptography padding module, which is the right library for the job - this isn't hand-rolled padding, so the scheme itself is standard and interoperable with anything else that speaks PKCS7.
Install is the usual pack story: ComfyUI Manager → search "ComfyUI ARG Toolkit" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
Restart and it's under ARG Toolkit/Cryptography/Modern/Padding. No models to download; the cryptography dependency comes in with the pack automatically.
One warning that's worth printing in big letters: as of version 2.2.1, the unpadding path in the shipped code has a bug - the unpad branch calls padder.finalize() on a variable that was never defined in that branch, so unpadding raises a NameError. Padding works fine; unpadding will throw. If that's you, the fix is to patch the padding method in custom_nodes/ComfyUI-ARG-Toolkit/src/cryptography_primitives/symm_padding.py to use unpadder.finalize() instead - a one-line change - or just do your unpadding with a standard Python cryptography snippet until the author ships a fix. The author describes the pack as an amateur project with light test coverage, and this is exactly the kind of edge case that slips through. It's a real gotcha, and knowing it'll save you twenty minutes of staring at a traceback.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| padding_data | BYTESLIKE | The data to pad or unpad. | |
| block_size | INT | 1280–2040 | The size of the block (in bits) that is padded onto the data. |
| algorithm | COMBO | The padding algorithm used. | |
| mode | BOOLEAN | true | Toggle between padding and unpadding. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| padded_data | BYTESLIKE | — |