OxL Reference

data rand

Cryptographically secure random numbers from the system generator (effect rand).

Example:

oxl✓ checked in CI
use std.crypto { rand }

fn main() io, rand {
  print("{rand.secure(32).len()} {rand.token(4).len()}")
}
Output
32 8
pub(api) data rand

Thread safety. safe from any task; every call draws fresh bytes from the system generator.

Since. 1.0.0-beta

Methods

secure(n: usize) -> bytes rand
n random bytes (n up to 16 MiB).
token(n: usize) -> str rand
A random token as lower-case hexadecimal text (2 * n characters).

Defined in: std/crypto/crypto.oxl:270

See also