From b74ae9a47d39ad5b0c6d5d060ae030df107916b9 Mon Sep 17 00:00:00 2001 From: Bernard Blackham Date: Fri, 25 Jun 2004 15:29:46 +0000 Subject: [PATCH] Need this :) --- sql-edition/servers/CRC.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sql-edition/servers/CRC.py diff --git a/sql-edition/servers/CRC.py b/sql-edition/servers/CRC.py new file mode 100644 index 0000000..512a7bd --- /dev/null +++ b/sql-edition/servers/CRC.py @@ -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) -- 2.20.1