Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: 64-bit digest algorithms (uniprot.org CRC64)

by erix (Prior)
on Nov 04, 2012 at 16:21 UTC ( [id://1002219]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1002219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-16 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found