Module B0_std.Hash

module Hash: sig .. end
Hash values and functions.

The property we want from these functions is speed and collision resistance. Build correctness depends on the latter.



Hash values


type t 
The type for hash values. All hash functions use this representation. It is not possible to distinguish them, except for their B0_std.Hash.length which might vary, or not.
val nil : t
nil is the only hash value of B0_std.Hash.length 0.
val length : t -> int
length h is the length of h in bytes.

Predicate and comparisons


val is_nil : t -> bool
is_nil h is true iff h is B0_std.Hash.nil.
val equal : t -> t -> bool
equal h0 h1 is true iff h0 and h1 are equal.
val compare : t -> t -> int
compare h0 h1 is a total order on hashes compatible with B0_std.Hash.equal.

Converting


val to_bytes : t -> string
to_bytes h is the sequence of bytes of h.
val of_bytes : string -> t
of_bytes s is the sequences of bytes of s as a hash value.
val to_hex : t -> string
to_hex h is B0_std.String.Ascii.to_hex (to_bytes h).
val of_hex : string -> (t, int) Pervasives.result
of_hex s is Result.map of_bytes (B0_std.String.Ascii.of_hex s).
val conv : t B0_std.Conv.t
conv converts using B0_std.Conv.string_bytes.
val pp : t B0_std.Fmt.t
pp formats using B0_std.Hash.to_hex or, if the hash is B0_std.Hash.nil, formats "nil".

Hash functions


module type T = sig .. end
The type for hash functions.
module Murmur3_128: T 
Murmur3_128 is the MurmurHash3 128-bit hash.
module Xxh_64: T 
Xxh_64 is the xxHash 64-bit hash.
val funs : unit -> (module B0_std.Hash.T) list
funs () is the list of available hash functions.
val add_fun : (module B0_std.Hash.T) -> unit
add_fun m adds m to the list returned by funs.