Question
Using Python 3. Need a python code that reads a jpg file, that has a size between 600kbs and 800kbs and places it into a
Using Python 3.
Need a python code that reads a jpg file, that has a size between 600kbs and 800kbs and places it into a large bytearray. A loop then reads a 1021 byte portion of the bytearray and creates a checksum.
Then a function that creates a checksum of the 1021 bytes by reading the first two bytes of the bytearray and performs bitwise addition of these two sets of 16 bits. If there is a carry bit then the function will add the carry to sum and then invert the bits of the sum. If there isn't a carry then the function just inverts the sum. This value is then added to the next sum. The loop repeats this action and add it to the previous sum. This loop much know when it gets to the end of the bytearray. This means that the final checksum will be of less than 1021 bytes. Finally, the checksum will be only two bytes and will represent the entire 1021 byte packet (unless the packet is less than 1021 bytes due to being the last portion of the file. This checksum must be 2 bytes in length because it will be added to a 1-byte sequence number and the 1021 bytes data packet to then be sent over a UDP socket to eventually transfer an entire file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started