Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Digest::MD5.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Digest::MD5 3"
132.TH Digest::MD5 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134Digest::MD5 \- Perl interface to the MD5 Algorithm
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 2
138\& # Functional style
139\& use Digest::MD5 qw(md5 md5_hex md5_base64);
140.Ve
141.PP
142.Vb 3
143\& $digest = md5($data);
144\& $digest = md5_hex($data);
145\& $digest = md5_base64($data);
146.Ve
147.PP
148.Vb 2
149\& # OO style
150\& use Digest::MD5;
151.Ve
152.PP
153.Vb 1
154\& $ctx = Digest::MD5->new;
155.Ve
156.PP
157.Vb 2
158\& $ctx->add($data);
159\& $ctx->addfile(*FILE);
160.Ve
161.PP
162.Vb 3
163\& $digest = $ctx->digest;
164\& $digest = $ctx->hexdigest;
165\& $digest = $ctx->b64digest;
166.Ve
167.SH "DESCRIPTION"
168.IX Header "DESCRIPTION"
169The \f(CW\*(C`Digest::MD5\*(C'\fR module allows you to use the \s-1RSA\s0 Data Security
170Inc. \s-1MD5\s0 Message Digest algorithm from within Perl programs. The
171algorithm takes as input a message of arbitrary length and produces as
172output a 128\-bit \*(L"fingerprint\*(R" or \*(L"message digest\*(R" of the input.
173.PP
174The \f(CW\*(C`Digest::MD5\*(C'\fR module provide a procedural interface for simple
175use, as well as an object oriented interface that can handle messages
176of arbitrary length and which can read files directly.
177.PP
178A binary digest will be 16 bytes long. A hex digest will be 32
179characters long. A base64 digest will be 22 characters long.
180.SH "FUNCTIONS"
181.IX Header "FUNCTIONS"
182The following functions can be exported from the \f(CW\*(C`Digest::MD5\*(C'\fR
183module. No functions are exported by default.
184.IP "md5($data,...)" 4
185.IX Item "md5($data,...)"
186This function will concatenate all arguments, calculate the \s-1MD5\s0 digest
187of this \*(L"message\*(R", and return it in binary form.
188.IP "md5_hex($data,...)" 4
189.IX Item "md5_hex($data,...)"
190Same as \fImd5()\fR, but will return the digest in hexadecimal form.
191.IP "md5_base64($data,...)" 4
192.IX Item "md5_base64($data,...)"
193Same as \fImd5()\fR, but will return the digest as a base64 encoded string.
194.Sp
195The base64 encoded string returned is not padded to be a multiple of 4
196bytes long. If you want interoperability with other base64 encoded
197md5 digests you might want to append the string \*(L"==\*(R" to the result.
198.SH "METHODS"
199.IX Header "METHODS"
200The following methods are available:
201.IP "$md5 = Digest::MD5\->new" 4
202.IX Item "$md5 = Digest::MD5->new"
203The constructor returns a new \f(CW\*(C`Digest::MD5\*(C'\fR object which encapsulate
204the state of the \s-1MD5\s0 message-digest algorithm. You can add data to
205the object and finally ask for the digest.
206.Sp
207If called as an instance method (i.e. \f(CW$md5\fR\->new) it will just reset the
208state the object to the state of a newly created object. No new
209object is created in this case.
210.IP "$md5\->reset" 4
211.IX Item "$md5->reset"
212This is just an alias for \f(CW$md5\fR\->new.
213.IP "$md5\->add($data,...)" 4
214.IX Item "$md5->add($data,...)"
215The \f(CW$data\fR provided as argument are appended to the message we
216calculate the digest for. The return value is the \f(CW$md5\fR object itself.
217.IP "$md5\->addfile($io_handle)" 4
218.IX Item "$md5->addfile($io_handle)"
219The \f(CW$io_handle\fR is read until \s-1EOF\s0 and the content is appended to the
220message we calculate the digest for. The return value is the \f(CW$md5\fR
221object itself.
222.Sp
223In most cases you want to make sure that the \f(CW$io_handle\fR is set up to
224be in \fIbinmode()\fR.
225.IP "$md5\->digest" 4
226.IX Item "$md5->digest"
227Return the binary digest for the message.
228.Sp
229Note that the \f(CW\*(C`digest\*(C'\fR operation is effectively a destructive,
230read-once operation. Once it has been performed, the \f(CW\*(C`Digest::MD5\*(C'\fR
231object is automatically \f(CW\*(C`reset\*(C'\fR and can be used to calculate another
232digest value.
233.IP "$md5\->hexdigest" 4
234.IX Item "$md5->hexdigest"
235Same as \f(CW$md5\fR\->digest, but will return the digest in hexadecimal form.
236.IP "$md5\->b64digest" 4
237.IX Item "$md5->b64digest"
238Same as \f(CW$md5\fR\->digest, but will return the digest as a base64 encoded
239string.
240.Sp
241The base64 encoded string returned is not padded to be a multiple of 4
242bytes long. If you want interoperability with other base64 encoded
243md5 digests you might want to append the string \*(L"==\*(R" to the result.
244.SH "EXAMPLES"
245.IX Header "EXAMPLES"
246The simplest way to use this library is to import the \fImd5_hex()\fR
247function (or one of its cousins):
248.PP
249.Vb 2
250\& use Digest::MD5 qw(md5_hex);
251\& print "Digest is ", md5_hex("foobarbaz"), "\en";
252.Ve
253.PP
254The above example would print out the message
255.PP
256.Vb 1
257\& Digest is 6df23dc03f9b54cc38a0fc1483df6e21
258.Ve
259.PP
260provided that the implementation is working correctly. The same
261checksum can also be calculated in \s-1OO\s0 style:
262.PP
263.Vb 1
264\& use Digest::MD5;
265.Ve
266.PP
267.Vb 4
268\& $md5 = Digest::MD5->new;
269\& $md5->add('foo', 'bar');
270\& $md5->add('baz');
271\& $digest = $md5->hexdigest;
272.Ve
273.PP
274.Vb 1
275\& print "Digest is $digest\en";
276.Ve
277.PP
278With \s-1OO\s0 style you can break the message arbitrary. This means that we
279are no longer limited to have space for the whole message in memory, i.e.
280we can handle messages of any size.
281.PP
282This is useful when calculating checksum for files:
283.PP
284.Vb 1
285\& use Digest::MD5;
286.Ve
287.PP
288.Vb 3
289\& my $file = shift || "/etc/passwd";
290\& open(FILE, $file) or die "Can't open '$file': $!";
291\& binmode(FILE);
292.Ve
293.PP
294.Vb 6
295\& $md5 = Digest::MD5->new;
296\& while (<FILE>) {
297\& $md5->add($_);
298\& }
299\& close(FILE);
300\& print $md5->b64digest, " $file\en";
301.Ve
302.PP
303Or we can use the builtin addfile method for more efficient reading of
304the file:
305.PP
306.Vb 1
307\& use Digest::MD5;
308.Ve
309.PP
310.Vb 3
311\& my $file = shift || "/etc/passwd";
312\& open(FILE, $file) or die "Can't open '$file': $!";
313\& binmode(FILE);
314.Ve
315.PP
316.Vb 1
317\& print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\en";
318.Ve
319.SH "SEE ALSO"
320.IX Header "SEE ALSO"
321Digest,
322Digest::MD2,
323Digest::SHA1,
324Digest::HMAC
325.PP
326\&\fImd5sum\fR\|(1)
327.PP
328\&\s-1RFC\s0 1321
329.SH "COPYRIGHT"
330.IX Header "COPYRIGHT"
331This library is free software; you can redistribute it and/or
332modify it under the same terms as Perl itself.
333.PP
334.Vb 3
335\& Copyright 1998-2002 Gisle Aas.
336\& Copyright 1995-1996 Neil Winton.
337\& Copyright 1991-1992 RSA Data Security, Inc.
338.Ve
339.PP
340The \s-1MD5\s0 algorithm is defined in \s-1RFC\s0 1321. The basic C code
341implementing the algorithm is derived from that in the \s-1RFC\s0 and is
342covered by the following copyright:
343.IP "\(bu" 4
344Copyright (C) 1991\-2, \s-1RSA\s0 Data Security, Inc. Created 1991. All
345rights reserved.
346.Sp
347License to copy and use this software is granted provided that it
348is identified as the \*(L"\s-1RSA\s0 Data Security, Inc. \s-1MD5\s0 Message-Digest
349Algorithm\*(R" in all material mentioning or referencing this software
350or this function.
351.Sp
352License is also granted to make and use derivative works provided
353that such works are identified as \*(L"derived from the \s-1RSA\s0 Data
354Security, Inc. \s-1MD5\s0 Message-Digest Algorithm\*(R" in all material
355mentioning or referencing the derived work.
356.Sp
357\&\s-1RSA\s0 Data Security, Inc. makes no representations concerning either
358the merchantability of this software or the suitability of this
359software for any particular purpose. It is provided \*(L"as is\*(R"
360without express or implied warranty of any kind.
361.Sp
362These notices must be retained in any copies of any part of this
363documentation and/or software.
364.PP
365This copyright does not prohibit distribution of any version of Perl
366containing this extension under the terms of the \s-1GNU\s0 or Artistic
367licenses.
368.SH "AUTHORS"
369.IX Header "AUTHORS"
370The original \s-1MD5\s0 interface was written by Neil Winton
371(\f(CW\*(C`N.Winton@axion.bt.co.uk\*(C'\fR).
372.PP
373This release was made by Gisle Aas <gisle@ActiveState.com>