Quick answer: use crypto.randomBytes() for cryptographically secure randomness in Node.js. const { randomBytes } = await import('node:crypto'); const buf = randomBytes(256); console.