vpe27339
vpe27339

Reputation: 91

CRC32 of binary data in python without last 4 bytes

I am trying to get the CRC32 of some binary data, except for the last 4 bytes.

My code so far:

with open('filename.ext','rb') as f:
    fileContent = f.read()
    file_size, = struct.unpack("i",f.read(:4))
    print hex(file_size)

I know that the :4 is wrong and I am still looking for how not to read the last 4 bytes and then get the crc32 for the other data.

Upvotes: 2

Views: 214

Answers (1)

MartyIX
MartyIX

Reputation: 28676

You can use indexing like this:

fileContent[:-4]

to skip the last 4 bytes.

Upvotes: 3

Related Questions