1
2
3
4 import warnings
5 warnings.warn("Bio.crc is deprecated; use crc32 and crc64 in Bio.SeqUtils.CheckSum instead", DeprecationWarning)
6
7
8 from binascii import crc32
9
10 _table_h = []
11
13 crcl = 0
14 crch = 0
15 for c in s:
16 shr = (crch & 0xFF) << 24
17 temp1h = crch >> 8
18 temp1l = (crcl >> 8) | shr
19 idx = (crcl ^ ord(c)) & 0xFF
20 crch = temp1h ^ _table_h[idx]
21 crcl = temp1l
22
23 return "CRC-%08X%08X" % (crch, crcl)
24
25
26 for i in range(256):
27 l = i
28 part_h = 0
29 for j in range(8):
30 rflag = l & 1
31 l >>= 1
32 if part_h & 1: l |= (1L << 31)
33 part_h >>= 1L
34 if rflag: part_h ^= 0xd8000000L
35 _table_h.append(part_h)
36