Skip to content

fletcher_32

fletcher_32(data): number

Defined in: checksum/fletcher_32.ts:18

Computes the Fletcher-32 checksum of data (John Fletcher, 1982).

Two running sums mod 65535 of 16-bit little-endian words — the data bytes are assembled into words two at a time, padding an odd-length input with an implicit trailing zero byte. Stronger error detection than fletcher_16 at comparable cost, and comparable to adler_32 with a slightly cheaper modulus (65535 rather than the prime 65521).

Complexity: O(n) in the byte length of data.

Uint8Array

The bytes to check.

number

An unsigned 32-bit checksum, the high 16 bits holding the sum of sums and the low 16 bits holding the sum of words.