line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Bubblegum Wrapper around Hashing Algorithms |
2
|
|
|
|
|
|
|
package Bubblegum::Wrapper::Digest; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
2305
|
use 5.10.0; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
150
|
|
5
|
4
|
|
|
4
|
|
289
|
use Bubblegum::Class; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
2894
|
use Digest::MD5 (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
59
|
|
8
|
4
|
|
|
4
|
|
2633
|
use Digest::SHA (); |
|
4
|
|
|
|
|
9970
|
|
|
4
|
|
|
|
|
109
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
1883
|
use Bubblegum::Exception; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1044
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'Bubblegum::Object::Instance'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.45'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub BUILD { |
17
|
4
|
|
|
4
|
0
|
9945
|
my $self = shift; |
18
|
4
|
50
|
|
|
|
81
|
$self->data->typeof('str') |
19
|
|
|
|
|
|
|
or Bubblegum::Exception->throw( |
20
|
|
|
|
|
|
|
verbose => 1, |
21
|
|
|
|
|
|
|
message => ref($self)->format( |
22
|
|
|
|
|
|
|
'Wrapper package "%s" requires string data' |
23
|
|
|
|
|
|
|
), |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub encode { |
28
|
8
|
|
|
8
|
1
|
31
|
my $self = shift; |
29
|
8
|
|
100
|
|
|
38
|
my $type = shift // 'md5_hex'; |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
|
|
|
13
|
my $encoder; |
32
|
8
|
|
|
|
|
24
|
my $md5 = [qw(md5 md5_hex)]; |
33
|
8
|
|
|
|
|
23
|
my $sha = [qw(sha1_base64 sha1 sha1_hex)]; |
34
|
8
|
|
|
|
|
16
|
my $hmc = [qw(hmac_sha1 hmac_sha1_hex)]; |
35
|
|
|
|
|
|
|
|
36
|
8
|
100
|
|
|
|
111
|
$encoder = 'Digest::MD5' if $md5->one('$a eq $b', $type); |
37
|
8
|
100
|
|
|
|
86
|
$encoder = 'Digest::SHA' if $sha->one('$a eq $b', $type); |
38
|
8
|
100
|
|
|
|
93
|
$encoder = 'Digest::SHA' if $hmc->one('$a eq $b', $type); |
39
|
|
|
|
|
|
|
|
40
|
8
|
50
|
|
|
|
28
|
return undef unless $encoder; |
41
|
8
|
|
|
|
|
428
|
return $encoder->can($type)->($self->data); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |