2

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.

1 Answer 1

3

You can use indexing like this:

fileContent[:-4]

to skip the last 4 bytes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.