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