Returns cryptographically secure random bytes as a Binary value, backed by the operating system CSPRNG. CFML has no primitive for raw entropy — generateSecretKey() only yields cipher-shaped key lengths as base64 text — so this covers PBKDF2 salts, nonces and opaque tokens. Count must be greater than 0 and at most 16777216 (16 MiB); a typo'd huge number fails loudly instead of exhausting memory. Available when the security cargo feature is enabled.
randomBytes(count)
→ returns binary
32 random bytes, base64-encoded for transport.
nonce = toBase64(randomBytes(32));
writeDump(len(nonce));
Expected Result: 44
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.