type state
type hash = int64
external init : (int64[@unboxed]) -> state = "caml_xx_init" "caml_xx_init_unboxed"
external update : state -> string -> unit = "caml_xx_update" [@@noalloc]
external update_int : state -> 'a -> unit = "caml_xx_update_int" [@@noalloc]
external update_int64 : state -> (int64[@unboxed]) -> unit
= "caml_xx_update_int64" "caml_xx_update_int64_unboxed"
[@@noalloc]
external digest : state -> (hash[@unboxed]) = "caml_xx_digest" "caml_xx_digest_unboxed" [@@noalloc]
external hash : string -> (int64[@unboxed]) -> (hash[@unboxed])
= "caml_xx_hash" "caml_xx_hash_unboxed"
[@@noalloc]
let equal (a : hash) (b : hash) = Int64.equal a b
let to_string (hash : hash) : string = Printf.sprintf "%016Lx" hash
let modulo hash modulus =
assert (modulus > 0);
(Int64.to_int hash |> abs) mod modulus