Need this :)
authorBernard Blackham <[email protected]>
Fri, 25 Jun 2004 15:29:46 +0000 (15:29 +0000)
committerBernard Blackham <[email protected]>
Fri, 25 Jun 2004 15:29:46 +0000 (15:29 +0000)
sql-edition/servers/CRC.py [new file with mode: 0644]

diff --git a/sql-edition/servers/CRC.py b/sql-edition/servers/CRC.py
new file mode 100644 (file)
index 0000000..512a7bd
--- /dev/null
@@ -0,0 +1,16 @@
+crctab = []
+CRC16 = 0x1021
+
+def do_crc(message, crc = 0):
+       for i in range(0,len(message)):
+               crc = ((crc << 8) ^ (crctab[(crc >> 8) ^ ord(message[i])])) & 0xffff
+       return crc
+
+# Generate crctab
+for val in range(0,256):
+       crc = val << 8;
+       for i in range(0,8):
+               crc = crc << 1
+               if (crc & 0x10000):
+                       crc = crc ^ CRC16
+       crctab.append(crc & 0xffff)

UCC git Repository :: git.ucc.asn.au