/[anoncvs]/projects/dispense2/sql-edition/servers/CRC.py


UCC Code Repository

Contents of /projects/dispense2/sql-edition/servers/CRC.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Fri Jun 25 15:29:46 2004 UTC (16 years, 10 months ago) by dagobah
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-python
Need this :)

1 crctab = []
2 CRC16 = 0x1021
3
4 def do_crc(message, crc = 0):
5 for i in range(0,len(message)):
6 crc = ((crc << 8) ^ (crctab[(crc >> 8) ^ ord(message[i])])) & 0xffff
7 return crc
8
9 # Generate crctab
10 for val in range(0,256):
11 crc = val << 8;
12 for i in range(0,8):
13 crc = crc << 1
14 if (crc & 0x10000):
15 crc = crc ^ CRC16
16 crctab.append(crc & 0xffff)

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26