Reputation: 51
I created a list of size 100 and populated the array with 8bit data in python using the following code and I want to calculate the CRC value using the zlib.crc32() function.
Init_RangenCrc8 = []
for i in range(0,100):
Init_RangenCrc8.append(random.randrange(0, 255, 1))
crc8_python = zlib.crc32(Init_RangenCrc8, 0xFFFF)
When I return and print the crc8_python, I am not getting any value back.
Any help would be appreciated, thanks.
Upvotes: 0
Views: 12859
Reputation: 19759
>>> help(zlib.crc32)
Help on built-in function crc32 in module zlib:
crc32(...)
crc32(string[, start]) -- Compute a CRC-32 checksum of string.
An optional starting value can be specified. The returned checksum is
a signed integer.
>>> zlib.crc32("".join(chr(random.randrange(0,255)) for _ in xrange(100)))
333158331
EDIT: code that uses the start value 0xFFFF
:
>>> text = "".join(chr(random.randrange(0,255)) for _ in xrange(100))
>>> zlib.crc32(text)
-964269250
>>> zlib.crc32(text, 0xFFFF)
2057263175
Upvotes: 7