1Digest(3)                        OCaml library                       Digest(3)
2
3
4

NAME

6       Digest - MD5 message digest.
7

Module

9       Module   Digest
10

Documentation

12       Module Digest
13        : sig end
14
15
16       MD5 message digest.
17
18       This  module  provides  functions to compute 128-bit 'digests' of arbi‐
19       trary-length strings or files. The algorithm used is MD5.
20
21       The MD5 hash function is not  cryptographically  secure.   Hence,  this
22       module  should  not  be used for security-sensitive applications.  More
23       recent, stronger cryptographic primitives should be used instead.
24
25
26
27
28
29       type t = string
30
31
32       The type of digests: 16-character strings.
33
34
35
36       val compare : t -> t -> int
37
38       The comparison function for 16-character digest, with the same specifi‐
39       cation  as  compare and the implementation shared with String.compare .
40       Along with the type t , this function compare allows the module  Digest
41       to be passed as argument to the functors Set.Make and Map.Make .
42
43
44       Since 4.00.0
45
46
47
48       val equal : t -> t -> bool
49
50       The equal function for 16-character digest.
51
52
53       Since 4.03.0
54
55
56
57       val string : string -> t
58
59       Return the digest of the given string.
60
61
62
63       val bytes : bytes -> t
64
65       Return the digest of the given byte sequence.
66
67
68       Since 4.02.0
69
70
71
72       val substring : string -> int -> int -> t
73
74
75       Digest.substring  s  ofs  len  returns the digest of the substring of s
76       starting at index ofs and containing len characters.
77
78
79
80       val subbytes : bytes -> int -> int -> t
81
82
83       Digest.subbytes s ofs len returns the digest of the  subsequence  of  s
84       starting at index ofs and containing len bytes.
85
86
87       Since 4.02.0
88
89
90
91       val channel : in_channel -> int -> t
92
93       If  len is nonnegative, Digest.channel ic len reads len characters from
94       channel  ic  and  returns  their  digest,  or  raises  End_of_file   if
95       end-of-file is reached before len characters are read.  If len is nega‐
96       tive,  Digest.channel  ic  len  reads  all  characters  from  ic  until
97       end-of-file is reached and return their digest.
98
99
100
101       val file : string -> t
102
103       Return the digest of the file whose name is given.
104
105
106
107       val output : out_channel -> t -> unit
108
109       Write a digest on the given output channel.
110
111
112
113       val input : in_channel -> t
114
115       Read a digest from the given input channel.
116
117
118
119       val to_hex : t -> string
120
121       Return the printable hexadecimal representation of the given digest.
122
123
124       Raises Invalid_argument if the argument is not exactly 16 bytes.
125
126
127
128       val from_hex : string -> t
129
130       Convert  a  hexadecimal  representation back into the corresponding di‐
131       gest.
132
133
134       Since 4.00.0
135
136
137       Raises Invalid_argument if the argument is not exactly  32  hexadecimal
138       characters.
139
140
141
142
143
144OCamldoc                          2022-07-22                         Digest(3)
Impressum