std.random_bytes

std

random_bytes(length) -> bytes

Read cryptographically secure random bytes

Returns length bytes from the kernel CSPRNG (getrandom(2), falling back to /dev/urandom). Accepts 0 to 65536 bytes.

This is the only randomness in this module fit for keys, tokens and salts. math.random backs everything else here, and its state is recoverable from a handful of outputs however well it was seeded.