Module crypto/random
crypto/random
Cryptographically secure random number generation. Uses OS entropy sources (getrandom on Linux, arc4random_buf on macOS, BCryptGenRandom on Windows, getentropy on WASI).
Example
{ random_u64, uuid_v4 } :: import "std/crypto/random";
id := uuid_v4(); // "550e8400-e29b-41d4-a716-446655440000"
Types
CryptoError
enum
CryptoError
Errors that can occur during cryptographic random operations.
Variants
| Variant | Fields | Description |
|---|---|---|
Unavailable | Platform does not support secure random generation. | |
Other | msg: String | Other platform-specific error. |
Trait Implementations
impl(CryptoError, ToString(...))
to_string : (
self ->
match(
self,
.Unavailable => `crypto: platform random unavailable`,
.Other(msg) => `crypto error: ${msg}`
)
)impl(CryptoError, Error())
Functions
random_bytes
function
random_u32
function
random_u64
function
random_f64
function
random_range
function
fn(min : i64, max : i64, exn : Exception) -> i64
Parameters
| Name | Type | Notes |
|---|---|---|
min | i64 | |
max | i64 | |
exn | Exception |
Returns: i64