Make.Hval empty : ctxAn empty hash context.
val init : unit -> ctxCreate a new hash state.
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)
Same as feed_bytes but for String.t.
val feed_bigstring : ctx -> ?off:int -> ?len:int -> Digestif.bigstring -> ctxSame as feed_bytes but for bigstring.
val feedi_bytes : ctx -> Bytes.t Digestif.iter -> ctxfeedi_bytes t iter = let r = ref t in iter (fun msg -> r := feed !r msg); !r
val feedi_string : ctx -> String.t Digestif.iter -> ctxSame as feed_bytes but for String.t.
val feedi_bigstring : ctx -> Digestif.bigstring Digestif.iter -> ctxSame as feed_bytes but for bigstring.
val hmac_init : key:string -> hmacCreate a new hmac state.
hmac_feed_bytes msg t adds informations in msg to t. hmac_feed is analogous to appending: hmac_feed (hmac_feed t msg1) msg2 = hmac_feed t (append msg1 msg2)
Same as hmac_feed_bytes but for String.t.
val hmac_feed_bigstring :
hmac ->
?off:int ->
?len:int ->
Digestif.bigstring ->
hmacSame as hmac_feed_bytes but for bigstring.
val hmac_feedi_bytes : hmac -> Bytes.t Digestif.iter -> hmachmac_feedi_bytes t iter = let r = ref t in iter (fun msg -> r := hmac_feed !r msg); !r
val hmac_feedi_string : hmac -> String.t Digestif.iter -> hmacSame as hmac_feedi_bytes but for String.t.
val hmac_feedi_bigstring : hmac -> Digestif.bigstring Digestif.iter -> hmacSame as hmac_feedi_bytes but for bigstring.
digest_bytes msg is the digest of msg.
digest_bytes msg = get (feed_bytes empty msg).
Same as digest_bytes but for a String.t.
val digest_bigstring : ?off:int -> ?len:int -> Digestif.bigstring -> tSame as digest_bytes but for a bigstring.
val digesti_bytes : Bytes.t Digestif.iter -> tdigesti_bytes iter = feedi_bytes empty iter |> get.
val digesti_string : String.t Digestif.iter -> tSame as digesti_bytes but for String.t.
val digesti_bigstring : Digestif.bigstring Digestif.iter -> tSame as digesti_bigstring but for bigstring.
Specialization of digesti_bytes with a list of Bytes.t (see iter).
Same as digestv_bytes but for String.t.
val digestv_bigstring : Digestif.bigstring list -> tSame as digestv_bytes but for bigstring.
hmac_bytes ~key bytes is the authentication code for Bytes.t under the secret key, generated using the standard HMAC construction over this hash algorithm.
Same as hmac_bytes but for String.t.
val hmac_bigstring :
key:string ->
?off:int ->
?len:int ->
Digestif.bigstring ->
tSame as hmac_bytes but for bigstring.
val hmaci_bytes : key:string -> Bytes.t Digestif.iter -> tAuthentication code under the secret key over a collection of Bytes.t.
val hmaci_string : key:string -> String.t Digestif.iter -> tSame as hmaci_bytes but for String.t.
val hmaci_bigstring : key:string -> Digestif.bigstring Digestif.iter -> tSame as hmaci_bytes but for bigstring.
Specialization of hmaci_bytes with a list of Bytes.t (see iter).
Same as hmacv_bytes but for String.t.
val hmacv_bigstring : key:string -> Digestif.bigstring list -> tSame as hmacv_bigstring but for bigstring.
val unsafe_compare : t Digestif.compareunsafe_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 Digestif.equalThe equal (constant-time) function for t.
val pp : t Digestif.ppPretty-printer of t.
val of_hex : string -> tof_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 optionof_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 -> tval consistent_of_hex_opt : string -> t optionval of_raw_string : string -> tof_raw_string s see s as a hash. Useful when reading serialized hashes.
val of_raw_string_opt : string -> t optionof_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 -> stringto_raw_string s is (s :> string).
val get_into_bytes : ctx -> ?off:int -> bytes -> unitget_into_bytes ctx ?off buf writes the result into the given buf at off (defaults to 0).
It's equivalent to:
let get_into_bytes ctx ?(off = 0) buf =
let t = get ctx in
let str = to_raw_string t in
Bytes.blit_string str 0 buf off digest_sizeexcept get_into_bytes does not allocate an intermediate string.