Fletcher's Checksum Calculator
Compute the Fletcher-16 checksum of a short ASCII string.
What it does
Fletcher's checksum is an error detection method devised by John G. Fletcher at Lawrence Livermore National Laboratory and published in 1982 in IEEE Transactions on Communications. It uses ordinary integer arithmetic instead of the polynomial division used by a cyclic redundancy check.
The 16 bit version keeps two sums. Starting from zero, each byte is added to A and then the new value of A is added to B. Both sums are reduced modulo 255, which is the largest value that fits in eight bits without being a power of two. At the end the two bytes are packed into a 16 bit word.
Because B depends on the running value of A, the checksum is position dependent. Rearranging the bytes usually changes the result, which a plain byte sum would not do. Fletcher reported that the method detects fewer error patterns than a CRC of the same width but is cheaper to compute in software.
This tool takes printable ASCII text and reports the final A and B sums plus the packed checksum in hexadecimal and decimal. The zlib manual notes that Adler-32 is a 32 bit extension of the Fletcher idea, so the two pages make a useful pair for comparison.
A checksum catches accidental changes to data. It is not a cryptographic hash and cannot detect deliberate tampering.
How to use
- Type a short string of printable ASCII characters into the input box.
- Read the hexadecimal checksum first, since that is the common display form.
- Check the decimal value if your system expects an unsigned 16 bit integer.
- Look at the final A and B sums to follow the arithmetic by hand.
- Use the table to see the same calculation for shorter strings.
- Compare with the Adler-32 page to see how the 32 bit version differs.
Formula
- A
- The running sum of the bytes, held in the low byte.
- B
- The running sum of the successive A values, held in the high byte.
- byte
- The ASCII code of the current character, from 32 to 126 here.
- 255
- The modulus, chosen as the largest eight bit value that is not a power of two.
The engine reads character codes directly because printable ASCII uses one byte per character. Using modulo 255 keeps both sums in a single byte, so packing them into 16 bits loses no information. The hexadecimal result is padded to four digits with leading zeros.
Worked example
Example: the string Wikipedia
Input Wikipedia, nine printable ASCII characters.
- Start with A = 0 and B = 0.
- Character W has code 87, so A = 87 and B = 87.
- Character i has code 105, so A = 192 and B = 87 + 192 = 279.
- After the third character k, A = 299 and B = 578.
- Continuing through the remaining six characters brings A to 154 and B to 238.
- Pack the words: 238 x 256 + 154 = 61,082.
- In hexadecimal that is 0xEE9A, which the tool reports as the checksum.
Reference table
| Text | A | B | Checksum |
|---|---|---|---|
| A | 65 | 65 | 0x4141 |
| Wiki | 149 | 217 | 0xD995 |
| Wikipedia | 154 | 238 | 0xEE9A |
Limits
- The input is restricted to printable ASCII so one character is exactly one byte.
- This is a 16 bit checksum with limited error detection power.
- The tool hashes text you paste. It does not read files or network streams.
- Adler-32 uses a different modulus and is not interchangeable with Fletcher-16.
Common mistakes
- Using modulus 256 instead of 255, which breaks the one byte bound.
- Adding the byte to B directly rather than adding the updated value of A.
- Comparing a Fletcher-16 value with an Adler-32 value for the same string.
- Pasting non ASCII text and expecting the same result as a UTF-8 byte stream.
- Treating a matching checksum as proof that data has not been altered on purpose.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is the Fletcher-16 checksum of Wikipedia?
0xEE9A, which is 61,082 in decimal, with A = 154 and B = 238.
What are A and B after the single byte 65?
A = 65 and B = 65. The packed checksum is 65 x 256 + 65 = 16,705 or 0x4141.
Why is 255 used as the modulus?
It is the largest value that fits in eight bits without being a power of two, which keeps the sums in one byte and improves detection of some error patterns.
Questions
What is Fletcher's checksum?
An integer arithmetic error detection method published by John G. Fletcher in 1982, using two running sums.
How is it different from a CRC?
It uses modular addition rather than polynomial division. It is faster in software but detects fewer error patterns.
How is it related to Adler-32?
Adler-32 uses the same idea with two 16 bit sums modulo 65521, giving a 32 bit checksum.
Why does the order of bytes matter?
Because B accumulates the running value of A, so the same bytes in a different order usually give a different result.
Can this detect all errors?
No. Any checksum with a fixed width has undetected error patterns, and an attacker can construct collisions.
Why are non ASCII characters rejected?
The algorithm works on bytes. Restricting input to printable ASCII keeps one character mapped to exactly one byte.
Sources
- Fletcher, An Arithmetic Checksum for Serial Transmissions, IEEE Transactions on Communications 1982
- zlib manual: checksum functions