package mec

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parameters

module D : sig ... end

Signature

val digest_size : int

Size of hash results, in bytes.

type ctx
type t
val empty : ctx

An empty hash context.

val init : ?personalisation:Bytes.t -> unit -> ctx

Create a new hash state.

val feed_bytes : ctx -> ?off:int -> ?len:int -> Bytes.t -> ctx

feed_bytes msg t adds informations in msg to t. feed is analogous to appending: feed (feed t msg1) msg2 = feed t (append msg1 msg2)

val feed_string : ctx -> ?off:int -> ?len:int -> String.t -> ctx

Same as feed_bytes but for String.t.

val feed_bigstring : ctx -> ?off:int -> ?len:int -> bigstring -> ctx

Same as feed_bytes but for bigstring.

val feedi_bytes : ctx -> Bytes.t iter -> ctx

feedi_bytes t iter = let r = ref t in iter (fun msg -> r := feed !r msg); !r

val feedi_string : ctx -> String.t iter -> ctx

Same as feed_bytes but for String.t.

val feedi_bigstring : ctx -> bigstring iter -> ctx

Same as feed_bytes but for bigstring.

val get : ctx -> t

get t is the digest corresponding to t.

val digest_bytes : ?off:int -> ?len:int -> Bytes.t -> t

digest_bytes msg is the digest of msg.

digest_bytes msg = get (feed_bytes empty msg).

val digest_string : ?off:int -> ?len:int -> String.t -> t

Same as digest_bytes but for a String.t.

val digest_bigstring : ?off:int -> ?len:int -> bigstring -> t

Same as digest_bytes but for a bigstring.

val digesti_bytes : Bytes.t iter -> t

digesti_bytes iter = feedi_bytes empty iter |> get.

val digesti_string : String.t iter -> t

Same as digesti_bytes but for String.t.

val digesti_bigstring : bigstring iter -> t

Same as digesti_bigstring but for bigstring.

val digestv_bytes : Bytes.t list -> t

Specialization of digesti_bytes with a list of Bytes.t (see iter).

val digestv_string : String.t list -> t

Same as digestv_bytes but for String.t.

val digestv_bigstring : bigstring list -> t

Same as digestv_bytes but for bigstring.

val unsafe_compare : t compare

unsafe_compare function returns 0 on equality and a negative/positive int depending on the difference (like String.compare). This is usually OK, but this is not constant time, so in some cases it could leak some information.

val equal : t equal

The equal (constant-time) function for t.

val pp : t pp

Pretty-printer of t.

val of_hex : string -> t

of_hex tries to parse an hexadecimal representation of t. of_hex raises an invalid_argument when input is malformed. We take only firsts digest_size hexadecimal values and ignore rest of input. If it has not enough hexadecimal values, trailing values of the output hash are zero (\x00),

val of_hex_opt : string -> t option

of_hex tries to parse an hexadecimal representation of t. of_hex returns None when input is malformed. We take only first digest_size hexadecimal values and ignore rest of input. If it has not enough hexadecimal values, trailing values of the output hash are zero (\x00).

val consistent_of_hex : string -> t

consistent_of_hex tries to parse an hexadecimal representation of t. consistent_of_hex raises an invalid_argument when input is malformed. However, instead of_hex, consistent_of_hex expects exactly {!digest_size} * 2 hexadecimal values (but continues to ignore whitespaces).

val consistent_of_hex_opt : string -> t option

consistent_of_hex_opt tries to parse an hexadecimal representation of t. consistent_of_hex returns None when input is malformed. However, instead of_hex, consistent_of_hex expects exactly {!digest_size} * 2 hexadecimal values (but continues to ignore whitespaces).

val to_hex : t -> string

to_hex makes a hex-decimal representation of t.

val of_raw_string : string -> t

of_raw_string s see s as a hash. Useful when reading serialized hashes.

val of_raw_string_opt : string -> t option

of_raw_string_opt s see s as a hash. Useful when reading serialized hashes. Returns None if s is not the digest_size bytes long.

val to_raw_string : t -> string

to_raw_string s is (s :> string).

OCaml

Innovation. Community. Security.