package nocrypto

  1. Overview
  2. Docs

Typed generation of a particular numeric type.

type t

The type of extracted values.

val gen : ?g:g -> t -> t

gen ~g n picks a value in the interval [0, n - 1] uniformly at random.

val gen_r : ?g:g -> t -> t -> t

gen_r ~g low high picks a value from the interval [low, high - 1] uniformly at random.

val gen_bits : ?g:g -> ?msb:int -> int -> t

gen_bits ~g ~msb n picks a bit-string n bits long, with msb most significant bits set, and interprets it as a t in big-endidan. This yields a value in the interval [2^(n-1) + ... + 2^(n-msb), 2^n - 1].

msb defaults to 0 which reduces gen_bits k to gen 2^k.

OCaml

Innovation. Community. Security.