Hash.MakeMake (A) is a hash module for the hashes of the algorithm specifed by A.
val algorithm : Algorithm.talgorithm is the hash algorithm.
length is the byte length of hashes produced by the function. Note that this can be 0 if the algorithm is unsupported.
module State : sig ... endHash state.
value state is the hash of state.
Warning. This must be called only once. It has an effect on state. Trying to do the following operations afterwards raises Bytesrw_crypto.Panic exceptions:
State.update or State.copy. Make a State.copy before if you want to get an intermediate hash.value or verify_value on state.verify_value state h checks in constant time that value state is equal to h.
Warning. This has all the caveats of value.
val string : string -> tstring s is the hash of s.
val bytes : bytes -> tbytes b is the hash of b.
val slice : Bytesrw.Bytes.Slice.t -> tslice s is the hash of the bytes in the range of s.
val reader : Bytesrw.Bytes.Reader.t -> treader r is the hash of stream r. This consumes the reader. See also reads.
val reads :
?state:State.t ->
Bytesrw.Bytes.Reader.t ->
Bytesrw.Bytes.Reader.t * State.treads 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 the final hash result use value on hstate once.
val writes :
?state:State.t ->
Bytesrw.Bytes.Writer.t ->
Bytesrw.Bytes.Writer.t * State.twrites ?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 the final hash result use value on hstate once.
equal h0 h1 uses Verify.equal_strings to assert the equality of h0 and h1.
val to_binary_string : t -> stringto_binary_string h is a binary representation of h of length length.
val of_binary_string : string -> (t, string) Stdlib.resultof_binary_string s is a hash from the binary representation stored in s.
val to_hex : t -> stringto_hex h is the binary representation of h using lowercase US-ASCII hex digits.
val of_hex : string -> (t, string) Stdlib.resultof_hex s parses a sequence of hex digits into a hash.
val pp : Stdlib.Format.formatter -> t -> unitpp formats hashes for inspection.