Module Import0.Digest
MD5 message digest.
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.
val compare : t -> t -> intThe comparison function for 16-character digest, with the same specification as
Stdlib.compareand the implementation shared withString.compare. Along with the typet, this functioncompareallows the moduleDigestto be passed as argument to the functorsSet.Make andMap.Make.- since
- 4.00.0
val string : string -> tReturn the digest of the given string.
val bytes : bytes -> tReturn the digest of the given byte sequence.
- since
- 4.02.0
val substring : string -> int -> int -> tDigest.substring s ofs lenreturns the digest of the substring ofsstarting at indexofsand containinglencharacters.
val subbytes : bytes -> int -> int -> tDigest.subbytes s ofs lenreturns the digest of the subsequence ofsstarting at indexofsand containinglenbytes.- since
- 4.02.0
val channel : Stdlib.in_channel -> int -> tIf
lenis nonnegative,Digest.channel ic lenreadslencharacters from channelicand returns their digest, or raisesEnd_of_fileif end-of-file is reached beforelencharacters are read. Iflenis negative,Digest.channel ic lenreads all characters fromicuntil end-of-file is reached and return their digest.
val file : string -> tReturn the digest of the file whose name is given.
val output : Stdlib.out_channel -> t -> unitWrite a digest on the given output channel.
val input : Stdlib.in_channel -> tRead a digest from the given input channel.
val to_hex : t -> stringReturn the printable hexadecimal representation of the given digest. Raise
Invalid_argumentif the argument is not exactly 16 bytes.
val from_hex : string -> tConvert a hexadecimal representation back into the corresponding digest. Raise
Invalid_argumentif the argument is not exactly 32 hexadecimal characters.- since
- 4.00.0