.TH "Digest" 3o 2020-10-30 OCamldoc "OCaml library" .SH NAME Digest \- MD5 message digest. .SH Module Module Digest .SH Documentation .sp Module .BI "Digest" : .B sig end .sp MD5 message digest\&. .sp This module provides functions to compute 128\-bit \&'digests\&' of arbitrary\-length strings or files\&. The digests are of cryptographic quality: it is very hard, given a digest, to forge a string having that digest\&. The algorithm used is MD5\&. This module should not be used for secure and sensitive cryptographic applications\&. For these kind of applications more recent and stronger cryptographic primitives should be used instead\&. .sp .sp .sp .I type t = .B string .sp The type of digests: 16\-character strings\&. .sp .I val compare : .B t -> t -> int .sp The comparison function for 16\-character digest, with the same specification as .ft B compare .ft R and the implementation shared with .ft B String\&.compare .ft R \&. Along with the type .ft B t .ft R , this function .ft B compare .ft R allows the module .ft B Digest .ft R to be passed as argument to the functors .ft B Set\&.Make .ft R and .ft B Map\&.Make .ft R \&. .sp .B "Since" 4.00.0 .sp .I val equal : .B t -> t -> bool .sp The equal function for 16\-character digest\&. .sp .B "Since" 4.03.0 .sp .I val string : .B string -> t .sp Return the digest of the given string\&. .sp .I val bytes : .B bytes -> t .sp Return the digest of the given byte sequence\&. .sp .B "Since" 4.02.0 .sp .I val substring : .B string -> int -> int -> t .sp .ft B Digest\&.substring s ofs len .ft R returns the digest of the substring of .ft B s .ft R starting at index .ft B ofs .ft R and containing .ft B len .ft R characters\&. .sp .I val subbytes : .B bytes -> int -> int -> t .sp .ft B Digest\&.subbytes s ofs len .ft R returns the digest of the subsequence of .ft B s .ft R starting at index .ft B ofs .ft R and containing .ft B len .ft R bytes\&. .sp .B "Since" 4.02.0 .sp .I val channel : .B in_channel -> int -> t .sp If .ft B len .ft R is nonnegative, .ft B Digest\&.channel ic len .ft R reads .ft B len .ft R characters from channel .ft B ic .ft R and returns their digest, or raises .ft B End_of_file .ft R if end\-of\-file is reached before .ft B len .ft R characters are read\&. If .ft B len .ft R is negative, .ft B Digest\&.channel ic len .ft R reads all characters from .ft B ic .ft R until end\-of\-file is reached and return their digest\&. .sp .I val file : .B string -> t .sp Return the digest of the file whose name is given\&. .sp .I val output : .B out_channel -> t -> unit .sp Write a digest on the given output channel\&. .sp .I val input : .B in_channel -> t .sp Read a digest from the given input channel\&. .sp .I val to_hex : .B t -> string .sp Return the printable hexadecimal representation of the given digest\&. .sp .B "Raises Invalid_argument" if the argument is not exactly 16 bytes\&. .sp .I val from_hex : .B string -> t .sp Convert a hexadecimal representation back into the corresponding digest\&. .sp .B "Since" 4.00.0 .sp .B "Raises Invalid_argument" if the argument is not exactly 32 hexadecimal characters\&. .sp