line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Digest::SHA3; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
255941
|
use strict; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
1816
|
|
4
|
6
|
|
|
6
|
|
128
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
227
|
|
5
|
6
|
|
|
6
|
|
33
|
use vars qw($VERSION); |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
403
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = 0.01; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
32
|
use base qw(Template::Plugin); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
7325
|
|
10
|
6
|
|
|
6
|
|
33143
|
use Template::Plugin; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
151
|
|
11
|
6
|
|
|
6
|
|
5803
|
use Template::Stash; |
|
6
|
|
|
|
|
169091
|
|
|
6
|
|
|
|
|
204
|
|
12
|
6
|
|
|
6
|
|
6413
|
use Digest::SHA3; |
|
6
|
|
|
|
|
22458
|
|
|
6
|
|
|
|
|
4091
|
|
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
|
53822
|
my ($class, $context, $options) = @_; |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
100
|
|
|
71
|
my $hashlen = $options || 256; |
24
|
10
|
|
|
|
|
57
|
$sha3 = new Digest::SHA3 $hashlen; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# now define the filter and return the plugin |
27
|
10
|
|
|
|
|
557
|
$context->define_filter('sha3', \&_sha3); |
28
|
10
|
|
|
|
|
535
|
$context->define_filter('sha3_hex', \&_sha3_hex); |
29
|
10
|
|
|
|
|
178
|
$context->define_filter('sha3_base64', \&_sha3_base64); |
30
|
10
|
|
|
|
|
193
|
return bless {}, $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _sha3 { |
34
|
4
|
|
|
4
|
|
14087
|
$sha3->reset(); |
35
|
4
|
|
|
|
|
286
|
$sha3->add(join('', @_)); |
36
|
4
|
|
|
|
|
46
|
return $sha3->digest(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _sha3_hex { |
40
|
7
|
|
|
7
|
|
256
|
$sha3->reset(); |
41
|
7
|
|
|
|
|
311
|
$sha3->add(join('', @_)); |
42
|
7
|
|
|
|
|
92
|
return $sha3->hexdigest(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _sha3_base64 { |
46
|
6
|
|
|
6
|
|
337
|
$sha3->reset(); |
47
|
6
|
|
|
|
|
132
|
$sha3->add(join('', @_)); |
48
|
6
|
|
|
|
|
134
|
return $sha3->b64digest(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |