//
// Hash32: hash a single message in one call, produce 32-bit output
//
420774
func Hash32(in []byte, seed uint32) uint32 {
    hash1, hash2 := uint64(seed),  uint64(seed)
    hash3, _ := SpookyHash128(in, hash1, hash2)
    return uint32(hash3)
}
220494
func (h *Hash) Sum32() (uint32, bool) {
	h32, ok := h.Hash.(hash.Hash32)
	if !ok {
		return 0, false
	}

	return h32.Sum32(), true
}
473324
func Hash(path string) (uint64, error) {
	file, err := os.Open(path)
	if err != nil {
		return 0, err
	}
	defer file.Close()
	return HashFile(file)
}
1140915
func hash(data string) string {
	return fmt.Sprintf("%x", sha256.Sum256([]byte(data)))
}
784037
func Hash64(in []byte, seed uint64) uint64 {
    hash1, hash2 := uint64(seed),  uint64(seed)
    hash3, _ := SpookyHash128(in, hash1, hash2)
    return hash3
}
1139851
func (t *NetworkDevice) Hash() uint64 {
	h := fnv.New64a()
	fmt.Fprintf(h, "%s\n%s\n%s\n%s",
		t.Metro,
		t.Role,
		t.Hostname,
		t.Hostgroup)
	return h.Sum64()
}
358051
func (vb *keyWriter) WriteUint32(num uint32) (int, error) {
	binary.BigEndian.PutUint32(vb.buffer[:4], num)
	vb.hash.Write(vb.buffer[:4])
	return 4, nil
}
763841
func (f *Filter) hash(data []byte) [2]uint64 {
	v1 := xxhash.Sum64(data)
	var v2 uint64
	if len(data) > 0 {
		b := data[len(data)-1] // We'll put the original byte back.
		data[len(data)-1] = byte(0)
		v2 = xxhash.Sum64(data)
		data[len(data)-1] = b
	}
	return [2]uint64{v1, v2}
}
988811
func HashString(input string) uint32 {

	hash := seed
	len := len(input)

	// step through the string 4 bytes at a time
	for i := 3; i < len; i += 4 {
		key := uint32(input[i-3]) | uint32(input[i-2]<<8) | uint32(input[i-1]<<16) | uint32(input[i]<<24)
		key = MixKey(key)
		hash = MixHash(hash, key)
	}

	// deal with remaining characters

	if len != 0 {
		var key uint32
		switch len % 4 {
		case 1:
			key = uint32(input[len-1])
		case 2:
			key = uint32(input[len-2]) | uint32(input[len-1]<<8)
		case 3:
			key = uint32(input[len-3]) | uint32(input[len-2]<<8) | uint32(input[len-1]<<16)
		}
		key = MixKey(key)
		hash = MixHash(hash, key)
	}

	return Finalize(hash, int32(len))
}
390790
func Hash(c interface{}, version int) (string, error) {
	return fmt.Sprintf("v%d_%x", version, Md5(c, version)), nil
}
63904
func HashFromBytes(data []byte) (Hash, error) {
	h := Hash{string(data)}
	if !h.IsValid() {
		return Hash{}, errors.WithStack(InvalidHashError{h})
	}
	return h, nil
}
687140
func HashString32(f func() hash.Hash32) func(string) uint32 {
	return func(s string) uint32 {
		h := f()
		h.Write([]byte(s))
		return h.Sum32()
	}
}
185535
func (r *Request) Hash() string {
	h := fnv.New64()
	h.Write([]byte(fmt.Sprintf("%s.%s", r.StackId, r.RequestId)))
	return base62.Encode(h.Sum64())
}
625658
func (bf *Filter) hash(hashNum uint32, data []byte) uint32 {
	// bitcoind: 0xfba4c795 chosen as it guarantees a reasonable bit
	// difference between hashNum values.
	//
	// Note that << 3 is equivalent to multiplying by 8, but is faster.
	// Thus the returned hash is brought into range of the number of bits
	// the filter has and returned.
	mm := MurmurHash3(hashNum*0xfba4c795+bf.msgFilterLoad.Tweak, data)
	return mm % (uint32(len(bf.msgFilterLoad.Filter)) << 3)
}
486358
func HashSimpleBase32(input, salt []byte, trim bool) string {
	if trim {
		return strings.Trim(base32.StdEncoding.EncodeToString(HashSimple(input, salt)), "=")
	}
	return base32.StdEncoding.EncodeToString(HashSimple(input, salt))
}
1360978
func (dec *Decoder) Uint32(v *uint32) error {
	err := dec.decodeUint32(v)
	if err != nil {
		return err
	}
	dec.called |= 1
	return nil
}
468508
func encodeHash(x uint64, p, pp uint8) uint32 {
	idx := uint32(bextr(x, 64-pp, pp))
	if bextr(x, 64-pp, pp-p) == 0 {
		zeros := bits.LeadingZeros64((bextr(x, 0, 64-pp)<<pp)|(1<<pp-1)) + 1
		return idx<<7 | uint32(zeros<<1) | 1
	}
	return idx << 1
}