Bug report: Wrong modulo value for Fletcher 16 integer truncate operations
- Dominant language
- JavaScript
- Stars
- 35.8k
- Forks
- 4.1k
- Avg merge
- 2d 26m
- Merged PRs (30d)
- 33
Description
**Describe the bug**
Wrong Fletcher 16 values are returned.
**To Reproduce**
Just calculate any Fletcher 16 value
1. Go to 'Favorites'
2. Click on 'From Hex'
3. Click on 'Delimiter'
4. Select 'Space'
5. Scroll down to 'Hashing'
6. Click on 'Fletcher-16 Checksum'
7. Go to Input
8. Write 'AA BB CC DD EE' without quotes
9. The returned checksum is 55 00 and it should be FC 4A
**Expected behaviour**
Calculate the correct Fletcher-16 value
**Additional context**
Modulo operation values used for integer truncation are wrong, the file CyberChef/src/core/operations/Fletcher16Checksum.mjs at line 41 has the following
`
for (let i = 0; i < input.length; i++) { \
a = (a + input[i]) % 0xff;
b = (b + a) % 0xff;
}
`
Which should be corrected as
`
for (let i = 0; i < input.length; i++) {
a = (a + input[i]) % 0x100;
b = (b + a) % 0x100;
}
`
Contributor guide
Assessment
This issue has not been assessed yet.