1
0
mirror of https://github.com/avakar/usbcorev.git synced 2024-10-22 02:17:39 +08:00
usbcorev/crc16.py

14 lines
257 B
Python
Raw Permalink Normal View History

import sys
while True:
crc = 0xffff
binary = raw_input('Enter sequence: ')
for ch in binary:
top = (crc & 0x8000) != 0
crc = (crc << 1) & 0xffff
if (ch == '1') != top:
crc = crc ^ 0x8005
print bin(crc)