tanszek:oktatas:techcomm:checksum
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tanszek:oktatas:techcomm:checksum [2026/10/19 17:51] – created knehez | tanszek:oktatas:techcomm:checksum [2026/10/19 17:55] (current) – knehez | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ==== Checksums ==== | + | ===== Checksums |
| A checksum is a small value calculated from a sequence of data. It helps us detect accidental changes during storage or transmission. | A checksum is a small value calculated from a sequence of data. It helps us detect accidental changes during storage or transmission. | ||
| Line 40: | Line 40: | ||
| The checksums differ, so the receiver detects an error. | The checksums differ, so the receiver detects an error. | ||
| - | == A limitation: order does not matter == | + | === A limitation: order does not matter |
| What happens if two bytes exchange positions? | What happens if two bytes exchange positions? | ||
| Line 56: | Line 56: | ||
| One value increased by 1 and another decreased by 1. This error remains undetected. | One value increased by 1 and another decreased by 1. This error remains undetected. | ||
| - | === Adler-32: using two sums === | + | ===== Adler-32: using two sums ===== |
| Adler-32 uses two running sums, called **A** and **B**. | Adler-32 uses two running sums, called **A** and **B**. | ||
| Line 79: | Line 79: | ||
| The prime number 65521 is part of the algorithm. In our small examples, the sums remain below this number, so the modulo operation does not change them. | The prime number 65521 is part of the algorithm. In our small examples, the sums remain below this number, so the modulo operation does not change them. | ||
| - | == Example: calculating the checksum == | + | === Example: calculating the checksum |
| Our data is: | Our data is: | ||
| Line 104: | Line 104: | ||
| B occupies the upper 16 bits, and A occupies the lower 16 bits. | B occupies the upper 16 bits, and A occupies the lower 16 bits. | ||
| - | == Detecting a change in order == | + | === Detecting a change in order === |
| Now exchange the first two bytes: | Now exchange the first two bytes: | ||
| Line 126: | Line 126: | ||
| Why? The first byte contributes to A earlier, so its effect is included in B more times than the effect of a later byte. | Why? The first byte contributes to A earlier, so its effect is included in B more times than the effect of a later byte. | ||
| - | === What can a checksum guarantee? === | + | ==== What can a checksum guarantee? |
| Adler-32 is used in the zlib compressed data format. It provides a practical way to detect accidental data corruption. | Adler-32 is used in the zlib compressed data format. It provides a practical way to detect accidental data corruption. | ||
tanszek/oktatas/techcomm/checksum.1792432294.txt.gz · Last modified: by knehez
