let random_state = Random.State.make_self_init type t = string let compare = String.compare let nil = "" let short ?(len) id = let id_len = String.length id in let l = match len with Some l -> l | None -> if id_len = 36 then 8 else 6 in String.sub id 0 (min l id_len) let generate ?(len=6) ?(seed=random_state ()) () = let b32 i = char_of_int @@ if i < 10 then i+48 else if i < 18 then i+87 else if i < 20 then i+88 else if i < 22 then i+89 else if i < 27 then i+90 else if i < 32 then i+91 else (invalid_arg ("id.char" ^ string_of_int i)) in let c _ = b32 (Random.State.int seed 31) in String.init len c