Random number generation.
public let blob : shared () -> async Blob
public func fast(seed : Nat64) : Random
Creates a fast pseudo-random number generator using the SFC64 algorithm. This provides statistical randomness suitable for simulations and testing, but should not be used for cryptographic purposes. The seed blob's first 8 bytes are used to initialize the PRNG.
public func crypto() : AsyncRandom
Creates a random number generator suitable for cryptography using entropy from the ICP management canister with automatic resupply.
public func fromGenerator(generator : () -> Blob) : Random
public func fromAsyncGenerator(generator : () -> async* Blob) : AsyncRandom
public let bool :
Random choice between true
and false
.
public let nat8 :
Random Nat8
value in the range [0, 256).
public func nat64() : Nat64
public func nat64Range(fromInclusive : Nat64, toExclusive : Nat64) : Nat64
public func natRange(fromInclusive : Nat, toExclusive : Nat) : Nat
public func intRange(fromInclusive : Int, toExclusive : Int) : Int
public let bool :
Random choice between true
and false
.
public let nat8 :
Random Nat8
value in the range [0, 256).
public func nat64() : async* Nat64
public func nat64Range(fromInclusive : Nat64, toExclusive : Nat64) : async* Nat64
public func natRange(fromInclusive : Nat, toExclusive : Nat) : async* Nat
public func intRange(fromInclusive : Int, toExclusive : Int) : async* Int