Module Core_kernel.Md5
This module implements the MD5 message-digest algorithm as described IETF RFC 1321. t is the result type and val digest_string : string -> t is the implementation of the algorithm itself.
This is currently a thin wrapper over the Digest module in INRIA's standard library.
module Stable : sig ... endmodule As_binary_string : sig ... endBoth bin_io and sexp serializations produce a binary 16-character string.
type t= Stable.V1.tIntended to represent a 16-byte string that is the output of MD5 algorithm.
Note that any 16-byte string can be converted to this type, so a value of type
tis not an evidence of someone having found an input corresponding to this output.
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if
texposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the varianttafterwards.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.t
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
include Interfaces.Comparable with type t := t
include Core_kernel__.Comparable_intf.S_common
include Base.Comparable.S
include Base__.Comparable_intf.Polymorphic_compare
val ascending : t -> t -> intascendingis identical tocompare.descending x y = ascending y x. These are intended to be mnemonic when used likeList.sort ~compare:ascendingandList.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.
val descending : t -> t -> intval between : t -> low:t -> high:t -> boolbetween t ~low ~highmeanslow <= t <= high
val clamp_exn : t -> min:t -> max:t -> tclamp_exn t ~min ~maxreturnst', the closest value totsuch thatbetween t' ~low:min ~high:maxis true.Raises if
not (min <= max).
val clamp : t -> min:t -> max:t -> t Base.Or_error.t
include Base.Comparator.S with type t := t
val comparator : (t, comparator_witness) Base.Comparator.comparator
include Base__.Comparable_intf.Validate with type t := t
val validate_lbound : min:t Base.Maybe_bound.t -> t Base.Validate.checkval validate_ubound : max:t Base.Maybe_bound.t -> t Base.Validate.checkval validate_bound : min:t Base.Maybe_bound.t -> max:t Base.Maybe_bound.t -> t Base.Validate.check
module Replace_polymorphic_compare : Core_kernel__.Comparable_intf.Polymorphic_compare with type t := tmodule Map : Map.S with type Key.t = t with type Key.comparator_witness = comparator_witnessmodule Set : Set.S with type Elt.t = t with type Elt.comparator_witness = comparator_witnessinclude Interfaces.Binable with type t := t
include Core_kernel__.Binable0.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if
texposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the varianttafterwards.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.t
include Interfaces.Hashable with type t := t
include Hashable.Common
val compare : t -> t -> Core_kernel__.Import.intval hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
val hashable : t Hashtbl.Hashable.t
module Hash_set : Hash_set.S with type elt = tmodule Hash_queue : Hash_queue.S with type key = tval to_binary : t -> stringBinary representations are 16 bytes long, and not human readable.
val of_binary_exn : string -> tval to_hex : t -> stringto_hexprints each byte oftas a big-endian sequence of 2 hex digits (e.g. byte 31 is written as "1f") and then concatenates them. For example,Md5.to_hex (Md5.digest_string "a") = Md5.to_hex ( Md5.of_binary_exn "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8\x31\xc3\x99\xe2\x69\x77\x26\x61") = "0cc175b9c0f1b6a831c399e269772661"
val of_hex_exn : string -> tThe inverse of
to_hex. This function ignores case. It will raise an exception if the string is not a 32-byte-long string of hex digits.
val digest_string : string -> tval digest_bytes : bytes -> tval digest_subbytes : bytes -> pos:int -> len:int -> tdigest_subbytes m ~pos ~lencomputes Md5 digest of the substring ofmof lengthlenstarting atpos.
val digest_file_blocking : string -> tdigest_file_blocking filenamereads the contents of filefilenameand computes its digest.
val digest_channel_blocking_without_releasing_runtime_lock : Stdlib.in_channel -> len:int -> tReads
lenbytes from the given channel and computes md5 digest of that.WARNING: This function does digest computation with OCaml global lock held, so it can be slow and make the other threads starve. See
digest_file_blocking.
val input_blocking : Stdlib.in_channel -> tReads an Md5 digest from the given channel (in a format written by
output_blocking)
val output_blocking : t -> Stdlib.out_channel -> unitWrites the Md5 digest to the given channel.
val string : string -> tval bytes : bytes -> tval subbytes : bytes -> int -> int -> tval from_hex : string -> tval file : string -> tval channel : Stdlib.in_channel -> int -> tval output : Stdlib.out_channel -> t -> unitval input : Stdlib.in_channel -> tval digest_bin_prot : 'a Bin_prot.Type_class.writer -> 'a -> tdigest_bin_prot w xdigests the serialization ofxbyw. It is a cheap way (in dev time) to compute the digest of an ocaml value, for a fixed and deterministic serialization function. It is currently implemented inefficiently and allocates large strings.For a more efficient and resource-aware version, use
Bigbuffer.add_bin_protandBigbuffer_blocking.md5.
val digest_bigstring : Bigstring.t -> tval digest_subbigstring : Bigstring.t -> pos:int -> len:int -> t