package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Core_kernel.Md5 end
module Stable = Core_kernel.Md5.Stable
module As_binary_string = Core_kernel.Md5.As_binary_string

Both bin_io and sexp serializations produce a binary 16-character string.

type t = Stable.V1.t

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 sig ... end
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
include Core_kernel.Interfaces.Comparable with type t := t
include Base.Comparable_intf.S with type t := t
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val equal : t -> t -> bool
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t
val clamp : t -> min:t -> max:t -> t Base__.Or_error.t
type comparator_witness = Core_kernel.Md5.comparator_witness
val comparator : (t, comparator_witness) Base__.Comparator.comparator
val validate_lbound : min:t Base__.Maybe_bound.t -> t Base__.Validate.check
val validate_ubound : max:t Base__.Maybe_bound.t -> t Base__.Validate.check
val validate_bound : min:t Base__.Maybe_bound.t -> max:t Base__.Maybe_bound.t -> t Base__.Validate.check
module Replace_polymorphic_compare = Core_kernel.Md5.Replace_polymorphic_compare
module Map = Core_kernel.Md5.Map
module Set = Core_kernel.Md5.Set
include Core_kernel.Interfaces.Binable with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader

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.

val bin_shape_t : Bin_prot.Shape.t
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_reader_t : t Bin_prot.Type_class.reader
include Core_kernel.Interfaces.Hashable with type t := t
include Core_kernel.Hashable.Common with type t := t
include sig ... end
val compare : t -> t -> Base.Int.t
val hash_fold_t : Ppx_hash_lib.Std.Hash.state -> t -> Ppx_hash_lib.Std.Hash.state
val hash : t -> Ppx_hash_lib.Std.Hash.hash_value
val hashable : t Core_kernel__.Hashtbl.Hashable.t
module Table = Core_kernel.Md5.Table
module Hash_set = Core_kernel.Md5.Hash_set
module Hash_queue = Core_kernel.Md5.Hash_queue
val digest_num_bytes : int

digest_num_bytes = 16 is the size of the digest in bytes.

val to_binary : t -> string

Binary representations are 16 bytes long, and not human readable.

val of_binary_exn : string -> t
val to_hex : t -> string

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"
val of_hex_exn : string -> t

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.

val digest_string : string -> t
val digest_bytes : bytes -> t
val digest_subbytes : bytes -> pos:int -> len:int -> t

digest_subbytes m ~pos ~len computes Md5 digest of the substring of m of length len starting at pos.

val digest_file_blocking_without_releasing_runtime_lock : string -> t

digest_file_blocking_without_releasing_runtime_lock filename reads the contents of file filename and computes its digest.

WARNING: This function does digest computation with OCaml global lock held, so it can be slow and make the other threads starve. Use Core.Md5.digest_file_blocking instead.

val digest_channel_blocking_without_releasing_runtime_lock : Pervasives.in_channel -> len:int -> t

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. Use Core.Md5.digest_fd_blocking instead.

val input_blocking : Pervasives.in_channel -> t

Reads an Md5 digest from the given channel (in a format written by output_blocking)

val output_blocking : t -> Pervasives.out_channel -> unit

Writes the Md5 digest to the given channel.

val string : string -> t
  • deprecated [since 2017-07] use [Md5.digest_string].
val bytes : bytes -> t
  • deprecated [since 2017-07] use [Md5.digest_bytes].
val subbytes : bytes -> int -> int -> t
  • deprecated [since 2017-07] use [Md5.digest_subbytes].
val from_hex : string -> t
  • deprecated [since 2017-07] use [of_hex_exn].
val file : string -> t
  • deprecated [since 2017-07] blocking functions should be avoided. Use [file_blocking] if you really want this.
val channel : Pervasives.in_channel -> int -> t
  • deprecated [since 2017-07] blocking functions should be avoided. Use [channel_blocking] if you really want this.
val output : Pervasives.out_channel -> t -> unit
  • deprecated [since 2017-07] Use [to_binary] together with [Out_channel.output_string]
val input : Pervasives.in_channel -> t
  • deprecated [since 2017-07] blocking functions should be avoided. Use [input_blocking] if you really want this.
val digest_fd_blocking : Unix.file_descr -> t

This is similar to digest_channel_blocking_without_releasing_runtime_lock with a difference that this releases the OCaml lock for its whole duration. Therefore, this can run in parallel with other OCaml threads and can be meaningfully used in In_thread.run.

The file descriptor must be open for reading and not be nonblocking, otherwise the function might fail non-deterministically.

val digest_file_blocking : string -> t

This function is equivalent in behavior to digest_file_blocking_without_releasing_runtime_lock, except this releases the OCaml lock for its whole duration. Therefore, this can run in parallel with other OCaml threads and can be meaningfully used in In_thread.run.

OCaml

Innovation. Community. Security.