line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Digest::SHA3; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
170862
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
206
|
|
4
|
6
|
|
|
6
|
|
23
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
170
|
|
5
|
6
|
|
|
6
|
|
24
|
use vars qw($VERSION); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
380
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = 0.02; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
29
|
use base qw(Template::Plugin); |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
4441
|
|
10
|
6
|
|
|
6
|
|
34263
|
use Template::Plugin; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
104
|
|
11
|
6
|
|
|
6
|
|
8101
|
use Template::Stash; |
|
6
|
|
|
|
|
68717
|
|
|
6
|
|
|
|
|
181
|
|
12
|
6
|
|
|
6
|
|
2531
|
use Digest::SHA3; |
|
6
|
|
|
|
|
11027
|
|
|
6
|
|
|
|
|
1436
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $sha3; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$Template::Stash::SCALAR_OPS->{'sha3'} = \&_sha3; |
17
|
|
|
|
|
|
|
$Template::Stash::SCALAR_OPS->{'sha3_hex'} = \&_sha3_hex; |
18
|
|
|
|
|
|
|
$Template::Stash::SCALAR_OPS->{'sha3_base64'} = \&_sha3_base64; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
10
|
|
|
10
|
1
|
21031
|
my ($class, $context, $options) = @_; |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
100
|
|
|
39
|
my $hashlen = $options || 256; |
24
|
10
|
|
|
|
|
33
|
$sha3 = new Digest::SHA3 $hashlen; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# now define the filter and return the plugin |
27
|
10
|
|
|
|
|
227
|
$context->define_filter('sha3', \&_sha3); |
28
|
10
|
|
|
|
|
153
|
$context->define_filter('sha3_hex', \&_sha3_hex); |
29
|
10
|
|
|
|
|
100
|
$context->define_filter('sha3_base64', \&_sha3_base64); |
30
|
10
|
|
|
|
|
107
|
return bless {}, $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _sha3 { |
34
|
4
|
|
|
4
|
|
7002
|
$sha3->reset(); |
35
|
4
|
|
|
|
|
68
|
$sha3->add(join('', @_)); |
36
|
4
|
|
|
|
|
39
|
return $sha3->digest(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _sha3_hex { |
40
|
7
|
|
|
7
|
|
187
|
$sha3->reset(); |
41
|
7
|
|
|
|
|
89
|
$sha3->add(join('', @_)); |
42
|
7
|
|
|
|
|
42
|
return $sha3->hexdigest(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _sha3_base64 { |
46
|
6
|
|
|
6
|
|
189
|
$sha3->reset(); |
47
|
6
|
|
|
|
|
86
|
$sha3->add(join('', @_)); |
48
|
6
|
|
|
|
|
49
|
return $sha3->b64digest(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |