Module B0.Hash

module Hash: sig .. end
Hash function.

The algorithm is unspecified but should be collision resistant, build correctness depends on it.



Hash values


val name : string
name is the name of the hash function. The hash function can be selected by using the B0_HASH environment variables. Available values are murmur3 and xxhash (default).
type t 
The type for hash values.
val zero : t
zero is the zero hash, a sequence of null bytes.
val to_bytes : t -> string
to_bytes h is the sequence of bytes of the hash h.
val to_hex : t -> string
to_hex h is the sequence of bytes of the hash h as US-ASCII hexadecimal digits.
val of_hex : string -> t option
of_hex s parses a sequence of US-ASCII hexadecimal digits from s into a hash. Guaranteed to succeed if s has been produced by B0.Hash.to_hex.
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.Hash.equal.
val pp : t B0.Fmt.t
pp ppf h prints an unspecified representation of h on ppf.

Hashing


val string : string -> t
string s is the hash of s.
val fd : Unix.file_descr -> t
fd fd mmaps and hashes the object pointed by fd.
Raises Unix.Unix_error on mmaping errors.
val file : B0.Fpath.t -> t B0.result
file p is the hash of file path p.

Hash sets and maps


type set 
The type for sets of hashes.
module Set: Set.S  with type elt = t and type t = set
Hash sets.
type +'a map 
The type for hash maps.
module Map: Map.S  with type key = t and type 'a t = 'a map
Hash maps.