in reply to
64-bit digest algorithms
I was looking for a CRC64 to checksum (protein) sequences in the same way as uniprot.org, and found Swiss::Knife (probably the code that Uniprot uses themselves). It is at sourceforge.
FWIW here is its CRC64.pm:
package SWISS::CRC64;
# ** Initialisation
#32 first bits of generator polynomial for CRC64
#the 32 lower bits are assumed to be zero
my $POLY64REVh = 0xd8000000;
my @CRCTableh = 256;
my @CRCTablel = 256;
my $initialized;
sub crc64 {
my $sequence = shift;
my $crcl = 0;
my $crch = 0;
if (!$initialized) {
$initialized = 1;
for (my $i=0; $i<256; $i++) {
my $partl = $i;
my $parth = 0;
for (my $j=0; $j<8; $j++) {
my $rflag = $partl & 1;
$partl >>= 1;
$partl |= (1 << 31) if $parth & 1;
$parth >>= 1;
$parth ^= $POLY64REVh if $rflag;
}
$CRCTableh[$i] = $parth;
$CRCTablel[$i] = $partl;
}
}
foreach (split '', $sequence) {
my $shr = ($crch & 0xFF) << 24;
my $temp1h = $crch >> 8;
my $temp1l = ($crcl >> 8) | $shr;
my $tableindex = ($crcl ^ (unpack "C", $_)) & 0xFF;
$crch = $temp1h ^ $CRCTableh[$tableindex];
$crcl = $temp1l ^ $CRCTablel[$tableindex];
}
return wantarray ? ($crch, $crcl) : sprintf("%08X%08X", $crch, $crcl
+);
}
1;
(I know; this is an old thread -- but I leave this here because it took me some time to find)