1Crypt::Digest::MD2(3) User Contributed Perl DocumentationCrypt::Digest::MD2(3)
2
3
4
6 Crypt::Digest::MD2 - Hash function MD2 [size: 128 bits]
7
9 ### Functional interface:
10 use Crypt::Digest::MD2 qw( md2 md2_hex md2_b64 md2_b64u
11 md2_file md2_file_hex md2_file_b64 md2_file_b64u );
12
13 # calculate digest from string/buffer
14 $md2_raw = md2('data string');
15 $md2_hex = md2_hex('data string');
16 $md2_b64 = md2_b64('data string');
17 $md2_b64u = md2_b64u('data string');
18 # calculate digest from file
19 $md2_raw = md2_file('filename.dat');
20 $md2_hex = md2_file_hex('filename.dat');
21 $md2_b64 = md2_file_b64('filename.dat');
22 $md2_b64u = md2_file_b64u('filename.dat');
23 # calculate digest from filehandle
24 $md2_raw = md2_file(*FILEHANDLE);
25 $md2_hex = md2_file_hex(*FILEHANDLE);
26 $md2_b64 = md2_file_b64(*FILEHANDLE);
27 $md2_b64u = md2_file_b64u(*FILEHANDLE);
28
29 ### OO interface:
30 use Crypt::Digest::MD2;
31
32 $d = Crypt::Digest::MD2->new;
33 $d->add('any data');
34 $d->addfile('filename.dat');
35 $d->addfile(*FILEHANDLE);
36 $result_raw = $d->digest; # raw bytes
37 $result_hex = $d->hexdigest; # hexadecimal form
38 $result_b64 = $d->b64digest; # Base64 form
39 $result_b64u = $d->b64udigest; # Base64 URL Safe form
40
42 Provides an interface to the MD2 digest algorithm.
43
45 Nothing is exported by default.
46
47 You can export selected functions:
48
49 use Crypt::Digest::MD2 qw(md2 md2_hex md2_b64 md2_b64u
50 md2_file md2_file_hex md2_file_b64 md2_file_b64u);
51
52 Or all of them at once:
53
54 use Crypt::Digest::MD2 ':all';
55
57 md2
58 Logically joins all arguments into a single string, and returns its MD2
59 digest encoded as a binary string.
60
61 $md2_raw = md2('data string');
62 #or
63 $md2_raw = md2('any data', 'more data', 'even more data');
64
65 md2_hex
66 Logically joins all arguments into a single string, and returns its MD2
67 digest encoded as a hexadecimal string.
68
69 $md2_hex = md2_hex('data string');
70 #or
71 $md2_hex = md2_hex('any data', 'more data', 'even more data');
72
73 md2_b64
74 Logically joins all arguments into a single string, and returns its MD2
75 digest encoded as a Base64 string, with trailing '=' padding.
76
77 $md2_b64 = md2_b64('data string');
78 #or
79 $md2_b64 = md2_b64('any data', 'more data', 'even more data');
80
81 md2_b64u
82 Logically joins all arguments into a single string, and returns its MD2
83 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
84
85 $md2_b64url = md2_b64u('data string');
86 #or
87 $md2_b64url = md2_b64u('any data', 'more data', 'even more data');
88
89 md2_file
90 Reads file (defined by filename or filehandle) content, and returns its
91 MD2 digest encoded as a binary string.
92
93 $md2_raw = md2_file('filename.dat');
94 #or
95 $md2_raw = md2_file(*FILEHANDLE);
96
97 md2_file_hex
98 Reads file (defined by filename or filehandle) content, and returns its
99 MD2 digest encoded as a hexadecimal string.
100
101 $md2_hex = md2_file_hex('filename.dat');
102 #or
103 $md2_hex = md2_file_hex(*FILEHANDLE);
104
105 BEWARE: You have to make sure that the filehandle is in binary mode
106 before you pass it as argument to the addfile() method.
107
108 md2_file_b64
109 Reads file (defined by filename or filehandle) content, and returns its
110 MD2 digest encoded as a Base64 string, with trailing '=' padding.
111
112 $md2_b64 = md2_file_b64('filename.dat');
113 #or
114 $md2_b64 = md2_file_b64(*FILEHANDLE);
115
116 md2_file_b64u
117 Reads file (defined by filename or filehandle) content, and returns its
118 MD2 digest encoded as a Base64 URL Safe string (see RFC 4648 section
119 5).
120
121 $md2_b64url = md2_file_b64u('filename.dat');
122 #or
123 $md2_b64url = md2_file_b64u(*FILEHANDLE);
124
126 The OO interface provides the same set of functions as Crypt::Digest.
127
128 new
129 $d = Crypt::Digest::MD2->new();
130
131 clone
132 $d->clone();
133
134 reset
135 $d->reset();
136
137 add
138 $d->add('any data');
139 #or
140 $d->add('any data', 'more data', 'even more data');
141
142 addfile
143 $d->addfile('filename.dat');
144 #or
145 $d->addfile(*FILEHANDLE);
146
147 add_bits
148 $d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
149 #or
150 $d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
151
152 hashsize
153 $d->hashsize;
154 #or
155 Crypt::Digest::MD2->hashsize();
156 #or
157 Crypt::Digest::MD2::hashsize();
158
159 digest
160 $result_raw = $d->digest();
161
162 hexdigest
163 $result_hex = $d->hexdigest();
164
165 b64digest
166 $result_b64 = $d->b64digest();
167
168 b64udigest
169 $result_b64url = $d->b64udigest();
170
172 · CryptX, Crypt::Digest
173
174 · <http://en.wikipedia.org/wiki/MD2_(cryptography)>
175
176
177
178perl v5.30.0 2019-07-26 Crypt::Digest::MD2(3)