line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Base32; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
26106
|
use 5.008001; |
|
2
|
|
|
|
|
6
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
37
|
|
5
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1157
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
our @EXPORT = qw(encode_base32 decode_base32); |
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
11
|
|
|
|
|
|
|
encode_rfc3548 decode_rfc3548 encode_09AV decode_09AV |
12
|
|
|
|
|
|
|
encode_base32hex decode_base32hex |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = "1.300_001"; |
16
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
1
|
529
|
sub encode { return encode_base32(@_) } |
19
|
1
|
|
|
1
|
1
|
2
|
sub encode_rfc3548 { return encode_base32(@_) } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub encode_base32 { |
22
|
5
|
|
|
5
|
1
|
7
|
my $arg = shift; |
23
|
5
|
100
|
|
|
|
13
|
return '' unless defined($arg); # mimic MIME::Base64 |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
17
|
$arg = unpack('B*', $arg); |
26
|
4
|
|
|
|
|
247
|
$arg =~ s/(.....)/000$1/g; |
27
|
4
|
|
|
|
|
5
|
my $l = length($arg); |
28
|
4
|
100
|
|
|
|
8
|
if ($l & 7) { |
29
|
3
|
|
|
|
|
4
|
my $e = substr($arg, $l & ~7); |
30
|
3
|
|
|
|
|
12
|
$arg = substr($arg, 0, $l & ~7); |
31
|
3
|
|
|
|
|
8
|
$arg .= "000$e" . '0' x (5 - length $e); |
32
|
|
|
|
|
|
|
} |
33
|
4
|
|
|
|
|
24
|
$arg = pack('B*', $arg); |
34
|
4
|
|
|
|
|
6
|
$arg =~ tr|\0-\37|A-Z2-7|; |
35
|
4
|
|
|
|
|
14
|
return $arg; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
1
|
5
|
sub decode { return decode_base32(@_) } |
39
|
1
|
|
|
1
|
1
|
3
|
sub decode_rfc3548 { return decode_base32(@_) } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decode_base32 { |
42
|
5
|
|
|
5
|
1
|
5
|
my $arg = shift; |
43
|
5
|
100
|
|
|
|
13
|
return '' unless defined($arg); # mimic MIME::Base64 |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
6
|
$arg =~ tr|A-Z2-7|\0-\37|; |
46
|
4
|
|
|
|
|
19
|
$arg = unpack('B*', $arg); |
47
|
4
|
|
|
|
|
269
|
$arg =~ s/000(.....)/$1/g; |
48
|
4
|
|
|
|
|
3
|
my $l = length $arg; |
49
|
4
|
100
|
|
|
|
12
|
$arg = substr($arg, 0, $l & ~7) if $l & 7; |
50
|
4
|
|
|
|
|
13
|
$arg = pack('B*', $arg); |
51
|
4
|
|
|
|
|
12
|
return $arg; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
1
|
3
|
sub encode_09AV { return encode_base32hex(@_) } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub encode_base32hex { |
57
|
4
|
|
|
4
|
1
|
376
|
my $arg = shift; |
58
|
4
|
100
|
|
|
|
11
|
return '' unless defined($arg); # mimic MIME::Base64 |
59
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
11
|
$arg = unpack('B*', $arg); |
61
|
3
|
|
|
|
|
202
|
$arg =~ s/(.....)/000$1/g; |
62
|
3
|
|
|
|
|
4
|
my $l = length($arg); |
63
|
3
|
100
|
|
|
|
8
|
if ($l & 7) { |
64
|
2
|
|
|
|
|
4
|
my $e = substr($arg, $l & ~7); |
65
|
2
|
|
|
|
|
9
|
$arg = substr($arg, 0, $l & ~7); |
66
|
2
|
|
|
|
|
8
|
$arg .= "000$e" . '0' x (5 - length $e); |
67
|
|
|
|
|
|
|
} |
68
|
3
|
|
|
|
|
17
|
$arg = pack('B*', $arg); |
69
|
3
|
|
|
|
|
5
|
$arg =~ tr|\0-\37|0-9A-V|; |
70
|
3
|
|
|
|
|
15
|
return $arg; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
1
|
1
|
2
|
sub decode_09AV { return decode_base32hex(@_) } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub decode_base32hex { |
76
|
4
|
|
|
4
|
1
|
5
|
my $arg = shift; |
77
|
4
|
100
|
|
|
|
12
|
return '' unless defined($arg); # mimic MIME::Base64 |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
5
|
$arg =~ tr|0-9A-V|\0-\37|; |
80
|
3
|
|
|
|
|
14
|
$arg = unpack('B*', $arg); |
81
|
3
|
|
|
|
|
160
|
$arg =~ s/000(.....)/$1/g; |
82
|
3
|
|
|
|
|
3
|
my $l = length($arg); |
83
|
3
|
100
|
|
|
|
8
|
$arg = substr($arg, 0, $l & ~7) if $l & 7; |
84
|
3
|
|
|
|
|
9
|
$arg = pack('B*', $arg); |
85
|
3
|
|
|
|
|
11
|
return $arg; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding utf8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
MIME::Base32 - Base32 encoder and decoder |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SYNOPSIS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#!/usr/bin/env perl |
99
|
|
|
|
|
|
|
use strict; |
100
|
|
|
|
|
|
|
use warnings; |
101
|
|
|
|
|
|
|
use MIME::Base32; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $encoded = encode_base32('Aladdin: open sesame'); |
104
|
|
|
|
|
|
|
my $decoded = decode_base32($encoded); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This module is for encoding/decoding data much the way that L does. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Prior to version 1.0, L used the C (or C<[0-9A-V]>) encoding and |
111
|
|
|
|
|
|
|
decoding methods by default. If you need to maintain that behavior, please call |
112
|
|
|
|
|
|
|
C or C functions directly. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Now, in accordance with L, |
115
|
|
|
|
|
|
|
L uses the C and C functions by default. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 FUNCTIONS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
The following primary functions are provided: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 decode |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Synonym for C |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 decode_rfc3548 |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Synonym for C |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 decode_base32 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $string = decode_base32($encoded_data); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Decode some encoded data back into a string of text or binary data. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 decode_09AV |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Synonym for C |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 decode_base32hex |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $string_or_binary_data = MIME::Base32::decode_base32hex($encoded_data); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Decode some encoded data back into a string of text or binary data. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 encode |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Synonym for C |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 encode_rfc3548 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Synonym for C |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 encode_base32 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $encoded = encode_base32("some string"); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Encode a string of text or binary data. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 encode_09AV |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Synonym for C |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 encode_base32hex |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my $encoded = MIME::Base32::encode_base32hex("some string"); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Encode a string of text or binary data. This uses the C (or C<[0-9A-V]>) method. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHORS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Jens Rehsack - - Current maintainer |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Chase Whitener |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Daniel Peder - sponsored by Infoset s.r.o., Czech Republic |
176
|
|
|
|
|
|
|
- http://www.infoset.com - Original author |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 BUGS |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Before reporting any new issue, bug or alike, please check |
181
|
|
|
|
|
|
|
L, |
182
|
|
|
|
|
|
|
L or |
183
|
|
|
|
|
|
|
L, respectively, whether |
184
|
|
|
|
|
|
|
the issue is already reported. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
187
|
|
|
|
|
|
|
C, or through the web interface at |
188
|
|
|
|
|
|
|
L. |
189
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress |
190
|
|
|
|
|
|
|
on your bug as I make changes. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Any and all criticism, bug reports, enhancements, fixes, etc. are appreciated. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SUPPORT |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
perldoc MIME::Base32 |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
You can also look for information at: |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=over 4 |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
L |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
L |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * MetaCPAN |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
L |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE INFORMATION |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Copyright (c) 2003-2010 Daniel Peder. All rights reserved. |
221
|
|
|
|
|
|
|
Copyright (c) 2015-2016 Chase Whitener. All rights reserved. |
222
|
|
|
|
|
|
|
Copyright (c) 2016 Jens Rehsack. All rights reserved. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
225
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 SEE ALSO |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L, L |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |