crypto.randomBytes()

A node:crypto function that returns bytes from a cryptographically secure random number generator, suitable for keys, IVs and tokens.

In more detail

Never use Math.random() for security values: it is predictable. crypto.randomUUID() is a convenient choice for random identifiers.

Related terms

Taught in

References