Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/CRC-32/Python/crc-32-2.py
Normal file
19
Task/CRC-32/Python/crc-32-2.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
def create_table():
|
||||
a = []
|
||||
for i in range(256):
|
||||
k = i
|
||||
for j in range(8):
|
||||
if k & 1:
|
||||
k ^= 0x1db710640
|
||||
k >>= 1
|
||||
a.append(k)
|
||||
return a
|
||||
|
||||
def crc_update(buf, crc):
|
||||
crc ^= 0xffffffff
|
||||
for k in buf:
|
||||
crc = (crc >> 8) ^ crc_table[(crc & 0xff) ^ k]
|
||||
return crc ^ 0xffffffff
|
||||
|
||||
crc_table = create_table()
|
||||
print(hex(crc_update(b"The quick brown fox jumps over the lazy dog", 0)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue