val compare : t -> t -> int
The comparison function for 16-character digest, with the same specification as
Stdlib.compare
and the implementation shared withString.compare
. Along with the typet
, this functioncompare
allows the moduleDigest
to be passed as argument to the functorsSet.Make
andMap.Make
.- since
- 4.00.0
val string : string -> t
Return the digest of the given string.
val bytes : bytes -> t
Return the digest of the given byte sequence.
- since
- 4.02.0
val substring : string -> int -> int -> t
Digest.substring s ofs len
returns the digest of the substring ofs
starting at indexofs
and containinglen
characters.
val subbytes : bytes -> int -> int -> t
Digest.subbytes s ofs len
returns the digest of the subsequence ofs
starting at indexofs
and containinglen
bytes.- since
- 4.02.0
val channel : Stdlib.in_channel -> int -> t
If
len
is nonnegative,Digest.channel ic len
readslen
characters from channelic
and returns their digest, or raisesEnd_of_file
if end-of-file is reached beforelen
characters are read. Iflen
is negative,Digest.channel ic len
reads all characters fromic
until end-of-file is reached and return their digest.
val file : string -> t
Return the digest of the file whose name is given.
val output : Stdlib.out_channel -> t -> unit
Write a digest on the given output channel.
val input : Stdlib.in_channel -> t
Read a digest from the given input channel.
val to_hex : t -> string
Return the printable hexadecimal representation of the given digest. Raise
Invalid_argument
if the argument is not exactly 16 bytes.
val from_hex : string -> t
Convert a hexadecimal representation back into the corresponding digest. Raise
Invalid_argument
if the argument is not exactly 32 hexadecimal characters.- since
- 4.00.0