Generating Random Data
Bindings for the random data generation API. See the libsodium randombytes docs for more information.
Constants
Buffer lengths (integer)
randombytes_SEEDBYTES
randombytes_random
var uint32 = sodium.randombytes_random()
Generates a random 32-bit unsigned integer [0, 0xffffffff]
(both inclusive).
randombytes_uniform
var uint = sodium.randombytes_uniform(upper_bound)
Generates a random 32-bit unsigned integer [0, upper_bound)
(last exclusive).
upper_bound
must be at most0xffffffff
randombytes_buf
sodium.randombytes_buf(buf)
Fills buf
with random data.
randombytes_buf_deterministic
sodium.randombytes_buf_deterministic(buf, seed)
Fills buf
with random data, generated from seed
.
seed
must be abuffer
of length at leastrandombytes_SEEDBYTES