I misinterpreted http://tools.ietf.org/html/rfc4880#section-5.5.3
and implemented the sum of 16-bit values, rather than the 16-bit sum
of 8-bit values.
Thanks to Szabolcs Nagy for pointing it out.
R=bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/
5372091
}
func mod64kHash(d []byte) uint16 {
- h := uint16(0)
- for i := 0; i < len(d); i += 2 {
- v := uint16(d[i]) << 8
- if i+1 < len(d) {
- v += uint16(d[i+1])
- }
- h += v
+ var h uint16
+ for _, b := range d {
+ h += uint16(b)
}
return h
}