File Coverage

blib/lib/Digest/Pearson/PurePerl.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 15 16 93.7


line stmt bran cond sub pod time code
1             package Digest::Pearson::PurePerl;
2              
3 1     1   576 use strict;
  1         1  
  1         28  
4 1     1   5 use Exporter;
  1         2  
  1         300  
5              
6             @Digest::Pearson::PurePerl::ISA = qw(Exporter);
7              
8             @Digest::Pearson::PurePerl::EXPORT_OK = qw(pearson);
9              
10             @Digest::Pearson::PurePerl::EXPORT = qw( );
11              
12             $Digest::Pearson::PurePerl::VERSION = "1.00";
13              
14             my @p_tbl = (
15             251,175,119,215, 81, 14, 79,191,103, 49,181,143,186,157, 0,232,
16             31, 32, 55, 60,152, 58, 17,237,174, 70,160,144,220, 90, 57,223,
17             59, 3, 18,140,111,166,203,196,134,243,124, 95,222,179,197, 65,
18             180, 48, 36, 15,107, 46,233,130,165, 30,123,161,209, 23, 97, 16,
19             40, 91,219, 61,100, 10,210,109,250,127, 22,138, 29,108,244, 67,
20             207, 9,178,204, 74, 98,126,249,167,116, 34, 77,193,200,121, 5,
21             20,113, 71, 35,128, 13,182, 94, 25,226,227,199, 75, 27, 41,245,
22             230,224, 43,225,177, 26,155,150,212,142,218,115,241, 73, 88,105,
23             39,114, 62,255,192,201,145,214,168,158,221,148,154,122, 12, 84,
24             82,163, 44,139,228,236,205,242,217, 11,187,146,159, 64, 86,239,
25             195, 42,106,198,118,112,184,172, 87, 2,173,117,176,229,247,253,
26             137,185, 99,164,102,147, 45, 66,231, 52,141,211,194,206,246,238,
27             56,110, 78,248, 63,240,189, 93, 92, 51, 53,183, 19,171, 72, 50,
28             33,104,101, 69, 8,252, 83,120, 76,135, 85, 54,202,125,188,213,
29             96,235,136,208,162,129,190,132,156, 38, 47, 1, 7,254, 24, 4,
30             216,131, 89, 21, 28,133, 37,153,149, 80,170, 68, 6,169,234, 151
31             );
32              
33              
34              
35             sub pearson
36             {
37 2     2 0 337 my @message = unpack("C*", shift);
38 2         43 my $pos = @message;
39 2         3 my $hash = @message & 0xFF;
40              
41 2         7 while ($pos > 0) {
42 1542         2459 $hash = $p_tbl[$hash ^ $message[--$pos]];
43             }
44              
45 2         42 return $hash;
46             }
47              
48             1;
49             __END__