Number of bytes stored in checksum

Asked 2 years ago, Updated 2 years ago, 72 views

I have a question about checksum.

Create a checksum for the binary file (up to 2048 kbyte).
The checksum will be minus every 1 byte and will be the total value.
See url below
About checksum

At that time, the place to store the checksum is 4 bytes.
So I have a question, what should I do if it doesn't fit into 4 bytes?

Also, I would appreciate it if you could tell me the general checksum (I don't know what's common...) and how to save it to a fixed number of bytes.

Thank you for your cooperation.

algorithm

2022-09-30 21:18

2 Answers

This kind of check code depends on the usage/purpose/acceptable amount of calculation.Common check codes are

·Parity
·Checksum
- Easy to calculate and fast
- Low transmission error detection capability
- Not useful for tampering detection
(Limited to cases where the highest priority is given to the 8-bit microcomputer, etc., using the check code.)

·CRC (Circular redundancy check)
- It's a little hard to calculate
-
High transmission error detection capability - It is impossible to detect tampering
(The balance between performance and calculation volume is well balanced and practical.) It is also used in rar zip etc.)

·Unidirectional hash function (SHA256, etc.)
- Computational and time consuming
- Transmission error detection is high (too expensive to use for transmission error detection)
- Ability to detect tampering
(It's hard to use a microcomputer with one chip due to the large amount of calculation, but the ability to check is the best.)

If you want me to select a check code of 4 bytes (32 bits) for the original 2MiB data,
The CRC32 is well balanced, so if you're an oiler, you'll adopt it.

Differentiating CRC32 from MD5


2022-09-30 21:18

If the value 0-255 is up to 2048K, it is not possible to underflow the signed 32-bit.You can prove it on your desk.

In overflow/underflow cases, it is common to compare only the low n bits of the checksum.


2022-09-30 21:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.