// Sha1 computes the SHA1 hash of a given string and encodes it with hexadecimal digits.
178190
func Sha1(str cty.Value) (cty.Value, error) {
	return Sha1Func.Call([]cty.Value{str})
}
1061498
func hashString(input string) string {
	defer loggerHighwayHasher.Reset()
	loggerHighwayHasher.Write([]byte(input))
	checksum := loggerHighwayHasher.Sum(nil)
	return hex.EncodeToString(checksum)
}
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))
}
233677
func SHA512(text []byte) string {
	result := sha512.Sum512(text)
	return hex.EncodeToString(result[:])
}
794126
func (s *Sha512Reader) Sha512() string {
	return hex.EncodeToString(s.hash.Sum(nil))
}
434758
func IdentifyHasher(encoded string) string {
	size := len(encoded)

	if size == 32 && !strings.Contains(encoded, "$") {
		return UnsaltedMD5Hasher
	}

	if size == 37 && strings.HasPrefix(encoded, "md5$$") {
		return UnsaltedMD5Hasher
	}

	if size == 46 && strings.HasPrefix(encoded, "sha1$$") {
		return UnsaltedSHA1Hasher
	}

	return strings.SplitN(encoded, "$", 2)[0]
}
812327
func Sha1Hash(bs []byte) []byte {
	crypt := sha1.New()
	crypt.Write(bs)
	return crypt.Sum(nil)
}
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
}
655840
func Sha1OfFile(path string) ([]byte, error) {
	f, err := os.Open(path)
	if err != nil {
		//fmt.Printf("os.Open(%s) failed with %s\n", path, err.Error())
		return nil, err
	}
	defer f.Close()
	h := sha1.New()
	_, err = io.Copy(h, f)
	if err != nil {
		//fmt.Printf("io.Copy() failed with %s\n", err.Error())
		return nil, err
	}
	return h.Sum(nil), nil
}
365895
func MustIDFromString(s string) sha1 {
	b, _ := hex.DecodeString(s)
	return MustID(b)
}
639969
func HmacSha1(secret string, message string) string {
	key := []byte(secret)
	h := hmac.New(sha1.New, key)
	h.Write([]byte(message))

	return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
249333
func String(s string, method crypto.Hash) (string, error) {
	h, err := createHash(method)
	if err != nil {
		return "", err
	}

	io.WriteString(h, s)

	return fmt.Sprintf("%x", h.Sum(nil)), nil
}
254882
func (t *SecureTrie) hashKey(key []byte) []byte {
	h := newHasher(nil)
	h.sha.Reset()
	h.sha.Write(key)
	buf := h.sha.Sum(t.hashKeyBuf[:0])
	returnHasherToPool(h)
	return buf
}
231597
func HmacSHA1(key, origData []byte) (sum []byte) {
	mac := hmac.New(sha1.New, key)
	mac.Write(origData)
	return mac.Sum(nil)
}
363068
func Sha512(data []byte) string {
	sha512 := sha512.New()
	sha512.Write(data)
	return hex.EncodeToString(sha512.Sum(nil))
}
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)
}
1117133
func (a Address) Hex() string {
	unchecksummed := hex.EncodeToString(a[:])
	sha := sha3.NewLegacyKeccak256()
	sha.Write([]byte(unchecksummed))
	hash := sha.Sum(nil)

	result := []byte(unchecksummed)
	for i := 0; i < len(result); i++ {
		hashByte := hash[i/2]
		if i%2 == 0 {
			hashByte = hashByte >> 4
		} else {
			hashByte &= 0xf
		}
		if result[i] > '9' && hashByte > 7 {
			result[i] -= 32
		}
	}
	return "0x" + string(result)
}