// FNVa computes a FNVa hash on a string
326113
func FNVa(s string) uint32 {
	h := fnv.New32a()
	_, _ = h.Write([]byte(s))
	return h.Sum32()
}
367336
func FastHash(input []byte) string {
	h := fnv.New32a()
	if _, err := h.Write(input); err != nil {
		log.Println("[ERROR] failed to write bytes: ", err)
	}

	return fmt.Sprintf("%x", h.Sum32())
}
347729
func HashData(src io.Reader) (string, error) {
	h := sha256.New()
	if _, err := io.Copy(h, src); err != nil {
		return "", err
	}
	return "sha256:" + hex.EncodeToString(h.Sum(nil)), nil
}
1313427
func computeHash(name string) string {
	data := []byte(name)
	hash := sha256.New()
	if _, err := hash.Write(data); err != nil {
		// Impossible case
		log.WithoutContext().WithField("OperationName", name).Errorf("Failed to create Span name hash for %s: %v", name, err)
	}

	return fmt.Sprintf("%x", hash.Sum(nil))[:TraceNameHashLength]
}
923103
func ComputeSHA256(data []byte) (hash []byte) {
	hash, err := factory.GetDefault().Hash(data, &bccsp.SHA256Opts{})
	if err != nil {
		panic(fmt.Errorf("Failed computing SHA256 on [% x]", data))
	}
	return
}
233644
func (h Hash) Uint64(key string) (uint64, error) {
	if value, ok := h[key]; ok {
		return value.Uint64()
	}
	return 0, errors.New(ErrInvalidKey, errorMessages, key)
}
555165
func accessTokenHash(alg jose.SignatureAlgorithm, accessToken string) (string, error) {
	newHash, ok := hashForSigAlg[alg]
	if !ok {
		return "", fmt.Errorf("unsupported signature algorithm: %s", alg)
	}

	hash := newHash()
	if _, err := io.WriteString(hash, accessToken); err != nil {
		return "", fmt.Errorf("computing hash: %v", err)
	}
	sum := hash.Sum(nil)
	return base64.RawURLEncoding.EncodeToString(sum[:len(sum)/2]), nil
}
871775
func (d *dir) calculateHash() {
	h := fnv.New64a()
	h.Write([]byte("dir "))
	for _, c := range d.children {
		h.Write([]byte(c.Name()))
		h.Write([]byte(" "))
		h.Write(c.Hash())
	}
	d.hash = h.Sum([]byte{})
}
335801
func keyToString(k []byte) string {
	if len(k) != lenHash {
		panic(fmt.Sprintf("bad hash passed to hashToKey: %x", k))
	}
	return fmt.Sprintf("%s%x", hashPrefix, k)[0:lenKey]
}
603496
func parseEnv(pay []byte) ([]byte, []byte) {

	l := pay[3]

	key := pay[4 : 4+l]

	offset := l + 8
	l = pay[7+l] // 4 for the offset, l for the key, 3 for the next three bytes.
	val := pay[offset : l+offset]

	return key, val

}
43853
func (s *FMSketch) NDV() int64 {
	return int64(s.mask+1) * int64(len(s.hashset))
}
1294565
func parseKeyVal(pair string) (string, string) {
	split := strings.Split(pair, ":")
	return split[0], split[1]
}
336761
func (m *meta) sum64() uint64 {
	var h = fnv.New64a()
	_, _ = h.Write((*[unsafe.Offsetof(meta{}.checksum)]byte)(unsafe.Pointer(m))[:])
	return h.Sum64()
}
412840
func fastHash(a int64, bs ...int64) int64 {
	buf := make([]byte, 8)
	hasher := fnv.New64a()
	w := func(v int64) {
		binary.LittleEndian.PutUint64(buf, uint64(v))
		if _, err := hasher.Write(buf); err != nil {
			panic(err)
		}
	}
	w(a)
	for _, b := range bs {
		w(b)
	}
	return int64(hasher.Sum64())
}
424184
func Hash(what []byte) uint64 {
	h := fnv.New64()
	h.Write(what)
	return h.Sum64()
}
492190
func computeHash(msg []byte) ([]byte, error) {
	h, err := cryptosuite.GetDefault().Hash(msg, cryptosuite.GetSHA256Opts())
	if err != nil {
		return nil, errors.WithMessage(err, "failed to compute tls cert hash")
	}
	return h, err
}
198217
func (dig *PvtDataDigest) Hash() (string, error) {
	b, err := proto.Marshal(dig)
	if err != nil {
		return "", err
	}
	return hex.EncodeToString(util.ComputeSHA256(b)), nil
}