[riot-notifications] [RIOT] sys/hashes: Add Fletcher's checksums (#3053)

Joakim Gebart notifications at github.com
Sat Jun 13 16:21:09 CEST 2015


Below is a naive Python implementation of fletcher16 that I have used before:

```python
def fletcher16(data):
    """
    Compute Fletcher's checksum (16 bit variant) of the given string.
    
    @param[in] data Input string
    @return the computed checksum as an integer
    """
    sum1 = 0
    sum2 = 0
    length = len(data)
    for pos in range(length):
        sum1 = (sum1 + data[pos]) % 255
        sum2 = (sum2 + sum1) % 255

    if sum1 == 0x00:
        sum1 = 0xFF
    if sum2 == 0x00:
        sum2 = 0xFF
    return (sum2 << 8) | sum1
```

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/3053#issuecomment-111713082
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150613/49c46900/attachment.html>


More information about the notifications mailing list