June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,28 +1,27 @@
|
|||
function crc32(crc::Int, str::ASCIIString)
|
||||
table = zeros(Uint32, 256)
|
||||
function crc32(crc::Int, str::String)
|
||||
table = zeros(UInt32, 256)
|
||||
|
||||
for i=0:255
|
||||
temp = i
|
||||
|
||||
for j=0:7
|
||||
if temp & 1 == 1
|
||||
temp >>= 1
|
||||
temp $= 0xedb88320
|
||||
for i in 0:255
|
||||
tmp = i
|
||||
for j in 0:7
|
||||
if tmp & 1 == 1
|
||||
tmp >>= 1
|
||||
tmp ⊻= 0xedb88320
|
||||
else
|
||||
temp >>= 1
|
||||
tmp >>= 1
|
||||
end
|
||||
end
|
||||
|
||||
table[i + 1] = temp
|
||||
table[i + 1] = tmp
|
||||
end
|
||||
|
||||
crc $= 0xffffffff
|
||||
crc ⊻= 0xffffffff
|
||||
|
||||
for i in map(Uint32, collect(str))
|
||||
crc = (crc >> 8) $ table[(crc & 0xff) $ i + 1]
|
||||
for i in UInt32.(collect(str))
|
||||
crc = (crc >> 8) ⊻ table[(crc & 0xff) ⊻ i + 1]
|
||||
end
|
||||
|
||||
crc $ 0xffffffff
|
||||
crc ⊻ 0xffffffff
|
||||
end
|
||||
|
||||
str = "The quick brown fox jumps over the lazy dog"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue