mirror of
https://github.com/avakar/usbcorev.git
synced 2024-10-22 02:17:39 +08:00
14 lines
246 B
Python
14 lines
246 B
Python
|
import sys
|
||
|
|
||
|
while True:
|
||
|
crc = 0x1f
|
||
|
|
||
|
binary = raw_input('Enter sequence: ')
|
||
|
for ch in binary:
|
||
|
top = (crc & 0x10) != 0
|
||
|
crc = (crc << 1) & 0x1f
|
||
|
if (ch == '1') != top:
|
||
|
crc = crc ^ 5
|
||
|
|
||
|
print bin(crc)
|