Module Bytesrw_xxhash.Xxh3_128

XXH3-128 hash.

Hashes

val id : string

id identifies the hash function.

val length : int

length is the byte length of hashes produced by the function.

type seed = int64

The type for seeds.

type secret = string

The type for secrets.

type t

The type for hashes.

module State : sig ... end

Hash state.

val value : State.t -> t

value state is the hash of state. This has no effect on state which can still be State.updated.

Hashing

val string : ?seed:seed -> string -> t

string s is the hash of s with seed seed (if any).

val bytes : ?seed:seed -> bytes -> t

bytes b is the hash of b with seed seed (if any).

val slice : ?seed:seed -> Bytesrw.Bytes.Slice.t -> t

slice s is the hash of the bytes in the range of s with seed seed (if any).

val reader : ?seed:seed -> Bytesrw.Bytes.Reader.t -> t

reader r is the hash of the stream r with seed seed (if any). This consumes the reader. See also reads.

Hashing streams

reads r is hr, hstate with:

  • hr a reader that taps the reads of r to update hstate.
  • hstate, a hash state of the reads made on hr so far. This is state if explicitely given, otherwise defaults to a fresh State.make.

To get intermediate or final hash results use value on hstate.

writes ?state w is hw, hstate with:

  • hw a writer that taps the writes to update hstate before giving them to w.
  • hstate, a hash state of the writes made on hw so far. This is state if explicitely given, otherwise defaults to a fresh State.make.

To get intermediate or final hash results use value on hstate.

Predicates and comparisons

val equal : t -> t -> bool

equal h0 h1 is true iff h0 and h1 are equal.

val compare : t -> t -> int

compare is a total order on hashes compatible with equal.

Converting

val to_binary_string : t -> string

to_binary_string h is a big-endian binary representation of h of length length.

val of_binary_string : string -> (t, string) Stdlib.result

of_binary_string s is a hash from the big-endian binary representation stored in s.

val to_hex : t -> string

to_hex h is the binary representation of h using lowercase US-ASCII hex digits.

val of_hex : string -> (t, string) Stdlib.result

of_hex s parses a sequence of hex digits into a hash.

val pp : Stdlib.Format.formatter -> t -> unit

pp formats hashes for inspection.