line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
41202
|
use strict; |
|
20
|
|
|
|
|
2597
|
|
|
20
|
|
|
|
|
7071
|
|
2
|
20
|
|
|
20
|
|
127
|
use warnings FATAL => 'all'; |
|
20
|
|
|
|
|
40
|
|
|
20
|
|
|
|
|
1862
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package HTML::Tested::Seal; |
5
|
20
|
|
|
20
|
|
121
|
use base 'Class::Singleton'; |
|
20
|
|
|
|
|
40
|
|
|
20
|
|
|
|
|
25380
|
|
6
|
20
|
|
|
20
|
|
45256
|
use Crypt::CBC; |
|
20
|
|
|
|
|
182383
|
|
|
20
|
|
|
|
|
2065
|
|
7
|
20
|
|
|
20
|
|
32141
|
use Digest::CRC qw(crc8); |
|
20
|
|
|
|
|
201571
|
|
|
20
|
|
|
|
|
2069
|
|
8
|
20
|
|
|
20
|
|
183
|
use Carp; |
|
20
|
|
|
|
|
68
|
|
|
20
|
|
|
|
|
2480
|
|
9
|
20
|
|
|
20
|
|
151
|
use Digest::MD5 qw(md5); |
|
20
|
|
|
|
|
127
|
|
|
20
|
|
|
|
|
1744
|
|
10
|
20
|
|
|
20
|
|
118
|
use bytes; |
|
20
|
|
|
|
|
36
|
|
|
20
|
|
|
|
|
193
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _new_instance { |
13
|
111
|
|
|
111
|
|
47888
|
my ($class, $key) = @_; |
14
|
111
|
|
|
|
|
388
|
my $self = bless({}, $class); |
15
|
111
|
50
|
|
|
|
433
|
confess "No key!" unless $key; |
16
|
111
|
|
|
|
|
610
|
my $iv = substr(md5($key), 0, 8); |
17
|
111
|
|
|
|
|
932
|
my $c = Crypt::CBC->new(-key => $key, -cipher => 'Blowfish' |
18
|
|
|
|
|
|
|
, -iv => $iv, -header => 'none'); |
19
|
111
|
50
|
|
|
|
45770
|
confess "No cipher!" unless $c; |
20
|
111
|
|
|
|
|
485
|
$self->{_cipher} = $c; |
21
|
111
|
|
|
|
|
628
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub encrypt { |
25
|
176
|
|
|
176
|
0
|
10306
|
my ($self, $data) = @_; |
26
|
176
|
100
|
|
|
|
773
|
confess "# No data to encrypt given!" unless defined($data); |
27
|
175
|
|
|
|
|
696
|
my $c = crc8($data); |
28
|
175
|
|
|
|
|
1265328
|
return $self->{_cipher}->encrypt_hex(pack("Ca*", $c, $data)); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub decrypt { |
32
|
124
|
|
|
124
|
0
|
6830
|
my ($self, $data) = @_; |
33
|
124
|
|
|
|
|
214
|
my $d; |
34
|
124
|
|
|
|
|
239
|
eval { $d = $self->{_cipher}->decrypt_hex($data) }; |
|
124
|
|
|
|
|
726
|
|
35
|
124
|
50
|
|
|
|
32824
|
return undef unless defined($d); |
36
|
|
|
|
|
|
|
|
37
|
124
|
|
|
|
|
440
|
my ($c, $res) = unpack("Ca*", $d); |
38
|
124
|
50
|
33
|
|
|
876
|
return undef unless (defined($c) && defined($res)); |
39
|
124
|
|
|
|
|
507
|
my $c1 = crc8($res); |
40
|
124
|
100
|
|
|
|
909201
|
return $c1 == $c ? $res : undef; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |