1Crypt::Digest::MD4(3) User Contributed Perl DocumentationCrypt::Digest::MD4(3)
2
3
4
6 Crypt::Digest::MD4 - Hash function MD4 [size: 128 bits]
7
9 ### Functional interface:
10 use Crypt::Digest::MD4 qw( md4 md4_hex md4_b64 md4_b64u
11 md4_file md4_file_hex md4_file_b64 md4_file_b64u );
12
13 # calculate digest from string/buffer
14 $md4_raw = md4('data string');
15 $md4_hex = md4_hex('data string');
16 $md4_b64 = md4_b64('data string');
17 $md4_b64u = md4_b64u('data string');
18 # calculate digest from file
19 $md4_raw = md4_file('filename.dat');
20 $md4_hex = md4_file_hex('filename.dat');
21 $md4_b64 = md4_file_b64('filename.dat');
22 $md4_b64u = md4_file_b64u('filename.dat');
23 # calculate digest from filehandle
24 $md4_raw = md4_file(*FILEHANDLE);
25 $md4_hex = md4_file_hex(*FILEHANDLE);
26 $md4_b64 = md4_file_b64(*FILEHANDLE);
27 $md4_b64u = md4_file_b64u(*FILEHANDLE);
28
29 ### OO interface:
30 use Crypt::Digest::MD4;
31
32 $d = Crypt::Digest::MD4->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 MD4 digest algorithm.
43
45 Nothing is exported by default.
46
47 You can export selected functions:
48
49 use Crypt::Digest::MD4 qw(md4 md4_hex md4_b64 md4_b64u
50 md4_file md4_file_hex md4_file_b64 md4_file_b64u);
51
52 Or all of them at once:
53
54 use Crypt::Digest::MD4 ':all';
55
57 md4
58 Logically joins all arguments into a single string, and returns its MD4
59 digest encoded as a binary string.
60
61 $md4_raw = md4('data string');
62 #or
63 $md4_raw = md4('any data', 'more data', 'even more data');
64
65 md4_hex
66 Logically joins all arguments into a single string, and returns its MD4
67 digest encoded as a hexadecimal string.
68
69 $md4_hex = md4_hex('data string');
70 #or
71 $md4_hex = md4_hex('any data', 'more data', 'even more data');
72
73 md4_b64
74 Logically joins all arguments into a single string, and returns its MD4
75 digest encoded as a Base64 string, with trailing '=' padding.
76
77 $md4_b64 = md4_b64('data string');
78 #or
79 $md4_b64 = md4_b64('any data', 'more data', 'even more data');
80
81 md4_b64u
82 Logically joins all arguments into a single string, and returns its MD4
83 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
84
85 $md4_b64url = md4_b64u('data string');
86 #or
87 $md4_b64url = md4_b64u('any data', 'more data', 'even more data');
88
89 md4_file
90 Reads file (defined by filename or filehandle) content, and returns its
91 MD4 digest encoded as a binary string.
92
93 $md4_raw = md4_file('filename.dat');
94 #or
95 $md4_raw = md4_file(*FILEHANDLE);
96
97 md4_file_hex
98 Reads file (defined by filename or filehandle) content, and returns its
99 MD4 digest encoded as a hexadecimal string.
100
101 $md4_hex = md4_file_hex('filename.dat');
102 #or
103 $md4_hex = md4_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 md4_file_b64
109 Reads file (defined by filename or filehandle) content, and returns its
110 MD4 digest encoded as a Base64 string, with trailing '=' padding.
111
112 $md4_b64 = md4_file_b64('filename.dat');
113 #or
114 $md4_b64 = md4_file_b64(*FILEHANDLE);
115
116 md4_file_b64u
117 Reads file (defined by filename or filehandle) content, and returns its
118 MD4 digest encoded as a Base64 URL Safe string (see RFC 4648 section
119 5).
120
121 $md4_b64url = md4_file_b64u('filename.dat');
122 #or
123 $md4_b64url = md4_file_b64u(*FILEHANDLE);
124
126 The OO interface provides the same set of functions as Crypt::Digest.
127
128 new
129 $d = Crypt::Digest::MD4->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::MD4->hashsize();
156 #or
157 Crypt::Digest::MD4::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/MD4>
175
176
177
178perl v5.32.1 2021-03-30 Crypt::Digest::MD4(3)