15 my $n = 2 * $table[-1];
16 push @table, $n > 0xff ? ($n ^ 0x31) & 0xff: $n;
21 # print "Table = ", join(' ', map { sprintf("%02x", $_) } @table), "\n";
23 for my $i (0x01 .. 0xff) {
24 $crctable[$i] ^= $table[0] if $i & 0x01;
25 $crctable[$i] ^= $table[1] if $i & 0x02;
26 $crctable[$i] ^= $table[2] if $i & 0x04;
27 $crctable[$i] ^= $table[3] if $i & 0x08;
28 $crctable[$i] ^= $table[4] if $i & 0x10;
29 $crctable[$i] ^= $table[5] if $i & 0x20;
30 $crctable[$i] ^= $table[6] if $i & 0x40;
31 $crctable[$i] ^= $table[7] if $i & 0x80;
34 # print "CRCtable = ", join(' ', map { sprintf("%02x", $_) } @crctable), "\n";
40 return digest(unpack("C*", $str));
49 for my $byte (@bytes) {
50 my $idx = $byte ^ $res;
51 $res = $crctable[$idx];