1 // Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com>
2 // All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
13 // Hash return hash of the given data.
14 func Hash(data []byte, seed uint32) uint32 {
15 // Similar to murmur hash
17 m = uint32(0xc6a4a793)
21 h = seed ^ (uint32(len(data)) * m)
25 for n := len(data) - len(data)%4; i < n; i += 4 {
26 h += binary.LittleEndian.Uint32(data[i:])
31 switch len(data) - i {
35 h += uint32(data[i+2]) << 16
38 h += uint32(data[i+1]) << 8