File: random.md

package info (click to toggle)
ocaml-eio 1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,548 kB
  • sloc: ml: 14,608; ansic: 1,237; makefile: 25
file content (22 lines) | stat: -rw-r--r-- 386 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Setting up the environment

```ocaml
# #require "eio_main";;
```

```ocaml
open Eio.Std
```

# Basic check for randomness

```ocaml
# Eio_main.run @@ fun env ->
  let src = Eio.Stdenv.secure_random env in
  let b1 = Cstruct.create 8 in
  let b2 = Cstruct.create 8 in
  Eio.Flow.read_exact src b1;
  Eio.Flow.read_exact src b2;
  assert (not (Cstruct.equal b1 b2));;
- : unit = ()
```