How To Calculate The Checksum

Table of contents:

How To Calculate The Checksum
How To Calculate The Checksum

Video: How To Calculate The Checksum

Video: How To Calculate The Checksum
Video: Checksum 2024, April
Anonim

To make sure that the file is transmitted over the communication line correctly, the sender pre-calculates its checksum, which it communicates to the recipient. The latter, having received the file, also calculates its checksum, and then checks whether it matches the one reported by the sender.

How to calculate the checksum
How to calculate the checksum

Instructions

Step 1

If the content of the file is written as a series of lines, each of which contains several tens of two-digit hexadecimal digits, add these numbers together in each of the lines. The amount also expressed in hexadecimal notation, write down to the right of the line. Calculate the checksums of all lines in this way. Then fold them together. The result, which in this case, too, will be expressed in hexadecimal notation, and will be the checksum of the entire file.

Step 2

In some cases, the checksum is too large and inconvenient for transmission. Then transfer together with the file only a few least significant digits of this amount (for example, four). The recipient in this case will have to compare the lower digits of the result with the number that you sent after calculating the checksum in the same way.

Step 3

More sophisticated checksum algorithms are used these days than simple addition and subsequent separation of the least significant digits. It is inconvenient to carry out calculations using these algorithms manually. One of them is called CRC (Cyclic Redundancy Check). The result of the calculation according to this algorithm is usually expressed not in hexadecimal, but in the binary number system. In order to calculate it, use the cksum utility (in Linux) or CRC-Check (in DOS or Windows).

Step 4

Along with CRC, modern algorithms for calculating MD5 and SHA checksums are now widely used. The utilities for calculating them are cross-platform. There are versions for both Linux and Windows (but not for DOS). The first one is used most often among them. In order to use it to calculate the checksum using the MD5 algorithm, regardless of which operating system you are using, enter the command: md5sum filename.рсш> filename.md5 You will get a second file, in which the checksum will be written. Send both files to the recipient. When he receives them, he will execute the following command: md5sum -c filename.md5 The utility will calculate the checksum of the first file with the information stored in the second, and then tell you if they match.

Recommended: