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