package sihl

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file random.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let () = Caml.Random.self_init ()

let rec chars result n =
  if n > 0
  then chars (List.cons (Char.chr (Caml.Random.int 255)) result) (n - 1)
  else result
;;

let bytes ~nr = chars [] nr

let base64 ~nr =
  Base64.encode_string
    ~alphabet:Base64.uri_safe_alphabet
    (bytes ~nr |> List.to_seq |> String.of_seq)
;;
OCaml

Innovation. Community. Security.