// SHA1 - Note: SHA-1 is cryptographically broken and should not be used for secure applications.
483971
func (f *CryptoFuncs) SHA1(input interface{}) string {
	in := toBytes(input)
	// nolint: gosec
	out := sha1.Sum(in)
	return fmt.Sprintf("%02x", out)
}
452553
func hash(data []byte, algorithm digestAlgorithm) string {
	switch algorithm {
	case SHA256:
		return fmt.Sprintf("%x", sha256.Sum256(data))
	default:
		return fmt.Sprintf("%x", md5.Sum(data))
	}
}
191113
func (s *Sha256Reader) Sha256() string {
	return hex.EncodeToString(s.hash.Sum(nil))
}
1222094
func SHA1RawPublicKey(cert *x509.Certificate) string {
	return fmt.Sprintf("%x", sha1.Sum(cert.RawSubjectPublicKeyInfo))
}
46036
func hash(key uint64) uint64 {
	key ^= key >> 33
	key *= 0xff51afd7ed558ccd
	key ^= key >> 33
	key *= 0xc4ceb9fe1a85ec53
	key ^= key >> 33
	return key
}
1258541
func Sha1SumWithSalt(seed, salt string) string {
	input := seed + salt

	result := fmt.Sprintf("%x", sha1.Sum([]byte(input)))

	log.Printf("Sha1Sum: seed[%s], salt[%s], result[%s]", seed, salt, result)

	return result
}
434080
func Hash(s string) string {
	return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}
873290
func Hash(h crypto.Hash, src io.Reader) (HexDigest, error) {
	a := h.New()
	_, err := io.Copy(a, src)
	if err != nil {
		return HexDigest(""), err
	}
	return Sum(a), nil
}
929075
func hash(body string) string {
	buf := sha256.New()
	fmt.Fprintf(buf, "blob %d", len(body))
	buf.Write([]byte{0})
	buf.Write([]byte(body))
	return "v2:" + hex.EncodeToString(buf.Sum(nil))
}
117575
func (f *CryptoFuncs) SHA512_256(input interface{}) string {
	in := toBytes(input)
	out := sha512.Sum512_256(in)
	return fmt.Sprintf("%02x", out)
}
1030093
func SHA1DeprecationMessages(chain []*x509.Certificate) []string {
	// record the most severe deprecation policy by each platform
	selectedPolicies := map[string]SHA1DeprecationPolicy{}
	for _, policy := range SHA1DeprecationPolicys {
		if policy.Flag(chain) {
			// only keep the policy with highest severity
			if selectedPolicies[policy.Platform].Severity < policy.Severity {
				selectedPolicies[policy.Platform] = policy
			}
		}
	}
	// build the message list
	list := []string{}
	for _, policy := range selectedPolicies {
		if policy.Severity > None {
			list = append(list, fmt.Sprintf("%s %s due to SHA-1 deprecation", policy.Platform, policy.Description))
		}
	}
	return list
}
440328
func (s sha1) String() string {
	result := make([]byte, 0, 40)
	hexvalues := []byte("0123456789abcdef")
	for i := 0; i < 20; i++ {
		result = append(result, hexvalues[s[i]>>4])
		result = append(result, hexvalues[s[i]&0xf])
	}
	return string(result)
}
50256
func (id sha1) Equal(s2 interface{}) bool {
	switch v := s2.(type) {
	case string:
		if len(v) != 40 {
			return false
		}
		return v == id.String()
	case []byte:
		if len(v) != 20 {
			return false
		}
		for i, v := range v {
			if id[i] != v {
				return false
			}
		}
	case sha1:
		for i, v := range v {
			if id[i] != v {
				return false
			}
		}
	default:
		return false
	}
	return true
}
1143194
func Sha1(c interface{}, version int) []byte {
	sum := sha1.Sum(Dump(c, version))
	return sum[:]
}
29077
func hash(settings map[string]interface{}) (string, error) {
	bytes, err := yaml.Marshal(settings)
	if err != nil {
		return "", errors.Trace(err)
	}
	hash := sha256.New()
	_, err = hash.Write(bytes)
	if err != nil {
		return "", errors.Trace(err)
	}
	return hex.EncodeToString(hash.Sum(nil)), nil
}
1292607
func NewID(b []byte) (sha1, error) {
	if len(b) != 20 {
		return sha1{}, fmt.Errorf("Length must be 20: %v", b)
	}
	return MustID(b), nil
}
15050
func (m *MemEngine) Hash(_ context.Context, d []byte) Hash {
	sum := sha512.Sum512(d)
	return Hash(sum[:])
}