Nodes/ComfyUI ARG Toolkit/Random Nonce Generator
ComfyUI Node

Random Nonce Generator

The pack's supply of actual entropy

By AzelusLightvale·Created 12 months ago·Updated 5 days ago· 1
Random Nonce Generator
    • rand_value
    byte_num12

    This is the least glamorous node in the pack and one of the most important. SystemRandom just generates random bytes - but the source matters: it uses your operating system's cryptographic random number generator (os.urandom under the hood). That's real entropy from the OS, not a seeded PRNG pretending to be random. The difference matters because this pack's salt, IV, and nonce inputs all point here.

    Look at any of the modern-crypto nodes - Scrypt_Derive says "Use SystemRandom to generate this" for the salt, SymmetricEncryptDecrypt says the same for the IV, and ChaCha20 wants a nonce. Randomness isn't flavor text in cryptography; a reused or predictable salt/IV/nonce can defeat the encryption outright. This node is the pack's way of making sure you never reach for a "random seed" node instead.

    How it works

    One input:

    • byte_num - how many random bytes you want. Default 12, minimum 1.

    One output: rand_value, a BYTESLIKE blob of that many bytes. Nothing else - no seed, no mode, no repeatability. You cannot get the same bytes twice, which is the entire point.

    What size to ask for

    • Salt for scrypt: 16 bytes is a comfortable floor; scrypt is fine with 32.
    • IV for CBC/CTR/OFB/CFB: 16 bytes (one AES block).
    • ChaCha20 nonce: 12 bytes - the classic ChaCha20 nonce size, and the default here for a reason.
    • XTS tweak: 16 bytes.

    Rule of thumb: if a node's tooltip says "use SystemRandom," it usually tells you the right size in the same sentence, and 16 covers most cases.

    A trap to dodge

    Because output is random every run, re-running the workflow invalidates anything encrypted with the old value. That's correct behavior for encryption - you save the salt/IV alongside the ciphertext so you can decrypt later, and you generate a fresh one each time you encrypt. The pack's SymmetricEncryptDecrypt will happily encrypt, but you own the job of storing the IV. Don't wire a fixed "seed" node in here; the whole point is that this one doesn't repeat.

    Installing it

    Ships in ComfyUI ARG Toolkit - ComfyUI Manager (search "ComfyUI ARG Toolkit") or:

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

    Restart ComfyUI. No model files or heavy deps beyond the pack's own.

    Common issues

    • "Must be bytes" errors downstream - you forgot to route rand_value into the salt/IV/nonce input of the crypto node; it's a wire, not a text field.
    • Everything decrypts to garbage - you generated a new IV on the decrypt run. Reuse the stored one.
    • If you need deterministic randomness for a puzzle mechanic (a seeded sequence), this is the wrong node on purpose - look at the pack's LSB steganography generators, which take m/n parameters for exactly that job.
    CategoryARG Toolkit/Utilities/Random

    Inputs (1)

    NameTypeDefaultDescription
    byte_numINT12

    Outputs (1)

    NameTypeDescription
    rand_valueBYTESLIKE