| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Digest::Adler32; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6025
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
468
|
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.03'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Digest::base; |
|
8
|
|
|
|
|
|
|
@ISA=qw(Digest::base); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
1
|
|
|
1
|
0
|
545
|
my $class = shift; |
|
13
|
1
|
50
|
|
|
|
6
|
if (ref $class) { |
|
14
|
0
|
|
|
|
|
0
|
$$class = 1; # reset |
|
15
|
0
|
|
|
|
|
0
|
return $class; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
1
|
|
|
|
|
4
|
my $adler_state = 1; |
|
18
|
1
|
|
|
|
|
4
|
return bless \$adler_state, $class; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub clone { |
|
22
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
23
|
0
|
|
|
|
|
0
|
my $adler_state = $$self; |
|
24
|
0
|
|
|
|
|
0
|
return bless \$adler_state, ref($self); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Based on RFC 1950 section 9 |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub add { |
|
30
|
7
|
|
|
7
|
0
|
11
|
my $self = shift; |
|
31
|
7
|
|
|
|
|
13
|
my $s1 = $$self & 0x0000FFFF; |
|
32
|
7
|
|
|
|
|
8
|
my $s2 = ($$self >> 16) & 0x0000FFFF; |
|
33
|
7
|
|
|
|
|
10
|
for my $buf (@_) { |
|
34
|
7
|
|
|
|
|
18
|
for my $c (unpack("C*", $buf)) { |
|
35
|
54
|
|
|
|
|
52
|
$s1 = ($s1 + $c ) % 65521; |
|
36
|
54
|
|
|
|
|
80
|
$s2 = ($s2 + $s1) % 65521; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
7
|
|
|
|
|
13
|
$$self = ($s2 << 16) + $s1; |
|
40
|
7
|
|
|
|
|
13
|
return $self; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub digest { |
|
44
|
10
|
|
|
10
|
0
|
852
|
my $self = shift; |
|
45
|
10
|
|
|
|
|
25
|
my $digest = pack("N", $$self); |
|
46
|
10
|
|
|
|
|
15
|
$$self = 1; # reset |
|
47
|
10
|
|
|
|
|
71
|
return $digest; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Digest::Adler32 - The Adler-32 checksum |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use Digest::Adler32; |
|
59
|
|
|
|
|
|
|
$a32 = Digest::Adler32->new; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# add stuff |
|
62
|
|
|
|
|
|
|
$a32->add($some_data); |
|
63
|
|
|
|
|
|
|
$a32->addfile(*STDIN); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# get digest |
|
66
|
|
|
|
|
|
|
print "Adler32: ", $a32->hexdigest, "\n"; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The C module implements the Adler-32 checksum as |
|
72
|
|
|
|
|
|
|
specified in RFC 1950. The interface provided by this module is |
|
73
|
|
|
|
|
|
|
specified in L, but no functional interface is provided. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
A binary digest will be 4 bytes long. A hex digest will be 8 |
|
76
|
|
|
|
|
|
|
characters long. A base64 digest will be 6 characters long. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L, L |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
|
85
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright 1996 L. Peter Deutsch and Jean-Loup Gailly |
|
88
|
|
|
|
|
|
|
Copyright 2001,2003 Gisle Aas |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |