.TH "Digest" 3o source: 2019-01-25 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 .B Pervasives\&.compare and the implementation shared with .B String\&.compare \&. Along with the type .B t , this function .B compare allows the module .B Digest to be passed as argument to the functors .B Set\&.Make and .B Map\&.Make \&. .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 .B Digest\&.substring s ofs len returns the digest of the substring of .B s starting at index .B ofs and containing .B len characters\&. .sp .I val subbytes : .B bytes -> int -> int -> t .sp .B Digest\&.subbytes s ofs len returns the digest of the subsequence of .B s starting at index .B ofs and containing .B len bytes\&. .sp .B "Since" 4.02.0 .sp .I val channel : .B Pervasives.in_channel -> int -> t .sp If .B len is nonnegative, .B Digest\&.channel ic len reads .B len characters from channel .B ic and returns their digest, or raises .B End_of_file if end\-of\-file is reached before .B len characters are read\&. If .B len is negative, .B Digest\&.channel ic len reads all characters from .B ic 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 Pervasives.out_channel -> t -> unit .sp Write a digest on the given output channel\&. .sp .I val input : .B Pervasives.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\&. Raise .B 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\&. Raise .B Invalid_argument if the argument is not exactly 32 hexadecimal characters\&. .sp .B "Since" 4.00.0 .sp