2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,3 +1,8 @@
|
|||
>>> s = 'The quick brown fox jumps over the lazy dog'
|
||||
>>> import zlib
|
||||
>>> hex(zlib.crc32('The quick brown fox jumps over the lazy dog'))
|
||||
>>> hex(zlib.crc32(s))
|
||||
'0x414fa339'
|
||||
|
||||
>>> import binascii
|
||||
>>> hex(binascii.crc32(s))
|
||||
'0x414fa339'
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
>>> import binascii
|
||||
>>> hex(binascii.crc32('The quick brown fox jumps over the lazy dog'))
|
||||
'0x414fa339'
|
||||
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