OxL Справочник OxL
РусскийEnglish

data rand

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

Example:

oxl✓ проверяется в CI
use std.crypto { rand }

fn main() io, rand {
  print("{rand.secure(32).len()} {rand.token(4).len()}")
}
Вывод
32 8
pub(api) data rand

Потокобезопасность. safe from any task; every call draws fresh bytes from the system generator.

С версии. 1.0.0-beta

Методы

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).

Определено в: std/crypto/crypto.oxl:270

См. также