line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Digest::SHA2; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1236534
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
254
|
|
4
|
6
|
|
|
6
|
|
36
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
211
|
|
5
|
6
|
|
|
6
|
|
31
|
use vars qw($VERSION); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
397
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = 0.01; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
33
|
use base qw(Template::Plugin); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
7300
|
|
10
|
6
|
|
|
6
|
|
39534
|
use Template::Plugin; |
|
6
|
|
|
|
|
93
|
|
|
6
|
|
|
|
|
183
|
|
11
|
6
|
|
|
6
|
|
20567
|
use Template::Stash; |
|
6
|
|
|
|
|
123521
|
|
|
6
|
|
|
|
|
222
|
|
12
|
6
|
|
|
6
|
|
6253
|
use Digest::SHA2; |
|
6
|
|
|
|
|
6053
|
|
|
6
|
|
|
|
|
2122
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $sha2; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$Template::Stash::SCALAR_OPS->{'sha2'} = \&_sha2; |
17
|
|
|
|
|
|
|
$Template::Stash::SCALAR_OPS->{'sha2_hex'} = \&_sha2_hex; |
18
|
|
|
|
|
|
|
$Template::Stash::SCALAR_OPS->{'sha2_base64'} = \&_sha2_base64; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
9
|
|
|
9
|
1
|
34351
|
my ($class, $context, $options) = @_; |
22
|
|
|
|
|
|
|
|
23
|
9
|
|
100
|
|
|
64
|
my $hashlen = $options || 256; |
24
|
9
|
|
|
|
|
87
|
$sha2 = new Digest::SHA2 $hashlen; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# now define the filter and return the plugin |
27
|
9
|
|
|
|
|
89
|
$context->define_filter('sha2', \&_sha2); |
28
|
9
|
|
|
|
|
220
|
$context->define_filter('sha2_hex', \&_sha2_hex); |
29
|
9
|
|
|
|
|
146
|
$context->define_filter('sha2_base64', \&_sha2_base64); |
30
|
9
|
|
|
|
|
156
|
return bless {}, $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _sha2 { |
34
|
4
|
|
|
4
|
|
10826
|
$sha2->reset(); |
35
|
4
|
|
|
|
|
48
|
$sha2->add(join('', @_)); |
36
|
4
|
|
|
|
|
19
|
return $sha2->digest(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _sha2_hex { |
40
|
7
|
|
|
7
|
|
312
|
$sha2->reset(); |
41
|
7
|
|
|
|
|
63
|
$sha2->add(join('', @_)); |
42
|
7
|
|
|
|
|
67
|
return $sha2->hexdigest(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _sha2_base64 { |
46
|
5
|
|
|
5
|
|
269
|
$sha2->reset(); |
47
|
5
|
|
|
|
|
46
|
$sha2->add(join('', @_)); |
48
|
5
|
|
|
|
|
1499
|
return $sha2->b64digest(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |