Skip to main content

Random Bytes

A block of cryptographically random bytes as hex, base64 or base64url. Never falls back to Math.random().

Random Bytes fills Length bytes from the platform's cryptographic random source (crypto.getRandomValues) and renders them in Encoding. If there is no such source it fails loudly rather than substituting Math.random() — a silent downgrade there produces output that looks identical and is worthless. Length counts BYTES, not characters: 32 bytes is 64 hex characters or 43 base64url characters. A length outside 1-4096 is refused rather than clamped.

When to use it

A nonce, a CSRF token, a PKCE verifier, an invite code, a one-time download key — anything that has to be unguessable. For an identifier that only has to be unique, the UUID node says so more clearly.

At a glance

CategoryUtilities
Type namenet.noodl.RandomBytes
Available inbrowser, cloud
SSR compatibilitysafe
Provided bynoodl-runtime

Inputs

Values

NameTypeDefaultDescription
encodingEnum (hex, base64, base64url)hexHow the bytes are rendered as text. Base64 URL is the safe one for a URL or a token
lengthNumber32How many random BYTES to generate (not characters — hex renders each byte as two). 1 to 4096

Signals

NameTypeDefaultDescription
generateSignalGenerates a fresh block of random bytes

Outputs

Values

NameTypeDefaultDescription
valueStringThe random bytes rendered in Encoding, replaced on every New

Signals

NameTypeDefaultDescription
completedSignalFires after every invocation, whatever the outcome — wire this to carry on regardless. Failure still fires and still carries its reason, so this cannot hide an error
doneSignalFires once fresh random bytes are available on Value

Failure outputs

NameTypeDefaultDescription
errorStringWhy no random bytes were produced
failureSignalFires when there is no cryptographic random source here, or Length is out of range. This node will not quietly substitute Math.random()

Patterns

  • New → Done → store or send. The value is replaced on every New, so read it from the Done path rather than later.

Watch out for

  • Treating Length as a character count. 16 bytes of hex is 32 characters.
  • Using this where a UUID is what the other system expects — the shapes are not interchangeable.

UUID, Hash, Unique Id

Generated

This page is generated from node-catalog-enriched.json. Do not edit it by hand — run npm run docs:nodes to regenerate, and fix the source enrichment instead.