package core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=743a141234e04210e295980f7a78a6d9
sha512=61b415f4fb12c78d30649fff1aabe3a475eea926ce6edb7774031f4dc7f37ea51f5d9337ead6ec73cd93da5fd1ed0f2738c210c71ebc8fe9d7f6135a06bd176f
doc/core/Core/Md5/index.html
Module Core.Md5
Source
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.
Both bin_io and sexp serializations produce a binary 16-character string.
Intended 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 t
is 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
include Ppx_hash_lib.Hashable.S with type t := t
include Interfaces.Comparable with type t := t
include Base.Comparable.S with type t := t
include Base.Comparisons.S with type t := t
ascending
is identical to compare
. descending x y = ascending y x
. These are intended to be mnemonic when used like List.sort ~compare:ascending
and List.sort ~cmp:descending
, since they cause the list to be sorted in ascending or descending order, respectively.
clamp_exn t ~min ~max
returns t'
, the closest value to t
such that between t' ~low:min ~high:max
is true.
Raises if not (min <= max)
.
include Interfaces.Binable with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
This function only needs implementation if t
exposed 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 variant t
afterwards.
digest_num_bytes = 16
is the size of the digest in bytes.
to_hex
prints each byte of t
as 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"
The 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.
digest_subbytes m ~pos ~len
computes Md5 digest of the substring of m
of length len
starting at pos
.
digest_file_blocking filename
reads the contents of file filename
and computes its digest.
Reads len
bytes 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
.
Reads an Md5 digest from the given channel (in a format written by output_blocking
)
Writes the Md5 digest to the given channel.
digest_bin_prot w x
digests the serialization of x
by w
. 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_prot
and Bigbuffer_blocking.md5
.