TLDR: Adler-32 is a checksum algorithm that helps verify the integrity of data by calculating a unique value based on the contents of the data. It was developed by Mark Adler in 1995 and is used for its speed and reliability.

Adler-32 is a type of checksum algorithm, which means it is used to check the integrity of data. It was created by Mark Adler in 1995 as a modification of Fletcher's checksum algorithm. Compared to other similar algorithms, Adler-32 prioritizes speed over reliability. It is more reliable than Fletcher-16 but slightly less reliable than Fletcher-32.

The Adler-32 checksum is widely used in the zlib compression library, which was also developed by Mark Adler. It is also used in the rsync utility, where a "rolling checksum" version of Adler-32 is employed.

To calculate an Adler-32 checksum, two 16-bit checksums, A and B, are calculated and then concatenated to form a 32-bit integer. The value of A is the sum of all the bytes in the data stream plus one, while B is the sum of the individual values of A from each step. The sums are performed modulo 65521, which is the largest prime number smaller than 2^16. The bytes are stored in network order, with B occupying the two most significant bytes.

An example of calculating the Adler-32 sum of the ASCII string "Wikipedia" is provided. The checksum is obtained by performing the necessary calculations on each character of the string. The modulo operation has no effect in this example because none of the values reached 65521.

Compared to the Fletcher checksum algorithm, Adler-32 has a few key differences. Firstly, Adler-32 sums are calculated modulo a prime number, while Fletcher sums are calculated modulo composite numbers. This allows Adler-32 to catch differences in certain combinations of bytes that Fletcher cannot detect. Secondly, Adler-32 computes the sums over 8-bit bytes instead of 16-bit words, resulting in twice the number of loop iterations. This makes Adler-32 slower than Fletcher's checksum for 16-bit word aligned data, but faster for byte-aligned data.

An example implementation of Adler-32 in the C programming language is provided, along with a more efficient implementation found in the zlib source code. The advantages and disadvantages of Adler-32 are also discussed. While it is faster than CRC-32 on many platforms, it can be easily forged and is therefore not suitable for protecting against intentional modification. Additionally, Adler-32 has a weakness for short messages with a few hundred bytes, as the checksums for these messages have a poor coverage of the available bits.

It is worth noting that Adler-32 has been shown to be weak for small incremental changes and for strings generated from a common prefix and consecutive numbers. As a result, it is recommended to use CRC32C instead of Adler-32 for the Stream Control Transmission Protocol (SCTP).

In summary, Adler-32 is a checksum algorithm developed by Mark Adler that is used to verify the integrity of data. It is faster than CRC-32 on many platforms but has some weaknesses for short messages. It is widely used in the zlib compression library and the rsync utility.

Related Links:

See the corresponding article on Wikipedia ยป

Note: This content was algorithmically generated using an AI/LLM trained-on and with access to Wikipedia as a knowledge source. Wikipedia content may be subject to the CC BY-SA license.