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
21       digest. The algorithm used is MD5. This module should not be  used  for
22       secure  and  sensitive  cryptographic  applications.  For these kind of
23       applications more recent and stronger cryptographic  primitives  should
24       be 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  Pervasives.compare  and  the  implementation  shared   with
41       String.compare  .  Along with the type t , this function compare allows
42       the module Digest to be passed as argument to the functors Set.Make and
43       Map.Make .
44
45
46       Since 4.00.0
47
48
49
50       val equal : t -> t -> bool
51
52       The equal function for 16-character digest.
53
54
55       Since 4.03.0
56
57
58
59       val string : string -> t
60
61       Return the digest of the given string.
62
63
64
65       val bytes : bytes -> t
66
67       Return the digest of the given byte sequence.
68
69
70       Since 4.02.0
71
72
73
74       val substring : string -> int -> int -> t
75
76
77       Digest.substring  s  ofs  len  returns the digest of the substring of s
78       starting at index ofs and containing len characters.
79
80
81
82       val subbytes : bytes -> int -> int -> t
83
84
85       Digest.subbytes s ofs len returns the digest of the  subsequence  of  s
86       starting at index ofs and containing len bytes.
87
88
89       Since 4.02.0
90
91
92
93       val channel : Pervasives.in_channel -> int -> t
94
95       If  len is nonnegative, Digest.channel ic len reads len characters from
96       channel  ic  and  returns  their  digest,  or  raises  End_of_file   if
97       end-of-file is reached before len characters are read.  If len is nega‐
98       tive,  Digest.channel  ic  len  reads  all  characters  from  ic  until
99       end-of-file is reached and return their digest.
100
101
102
103       val file : string -> t
104
105       Return the digest of the file whose name is given.
106
107
108
109       val output : Pervasives.out_channel -> t -> unit
110
111       Write a digest on the given output channel.
112
113
114
115       val input : Pervasives.in_channel -> t
116
117       Read a digest from the given input channel.
118
119
120
121       val to_hex : t -> string
122
123       Return  the  printable  hexadecimal representation of the given digest.
124       Raise 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
131       digest.  Raise Invalid_argument if the argument is not exactly 32 hexa‐
132       decimal characters.
133
134
135       Since 4.00.0
136
137
138
139
140
141OCamldoc                          2019-02-02                         Digest(3)
Impressum