// GeoHash returns the geohash string of a point representing a lng/lat location.
// The resulting hash will be `GeoHashPrecision` characters long, default is 12.
// Optionally one can include their required number of chars precision.
770124
func (p *Point) GeoHash(chars ...int) string {
	precision := GeoHashPrecision
	if len(chars) > 0 {
		precision = chars[0]
	}

	// 15 must be greater than GeoHashPrecision. If not, panic!!
	var result [15]byte

	hash := p.GeoHashInt64(5 * precision)
	for i := 1; i <= precision; i++ {
		result[precision-i] = byte(base32[hash&0x1F])
		hash >>= 5
	}

	return string(result[:precision])
}
77862
func (p Point) String() string {
	return fmt.Sprintf("Point(%f, %f)", p.Latitude, p.Longitude)
}
232640
func (p *parser) parseHash() *ast.Hash {
	var pairs []*ast.HashPair

	for p.isHashSegment() {
		pairs = append(pairs, p.parseHashSegment())
	}

	firstLoc := pairs[0].Location()

	result := ast.NewHash(firstLoc.Pos, firstLoc.Line)
	result.Pairs = pairs

	return result
}
374971
func (search *Search) Location(lat, lng, location string) (*SearchResult, error) {
	insta := search.inst
	q := map[string]string{
		"rank_token":     insta.rankToken,
		"latitude":       lat,
		"longitude":      lng,
		"ranked_content": "true",
	}

	if location != "" {
		q["search_query"] = location
	} else {
		q["timestamp"] = strconv.FormatInt(time.Now().Unix(), 10)
	}

	body, err := insta.sendRequest(
		&reqOptions{
			Endpoint: urlSearchLocation,
			Query:    q,
		},
	)
	if err != nil {
		return nil, err
	}

	res := &SearchResult{}
	err = json.Unmarshal(body, res)
	return res, err
}
844522
func Hash(s string) string {
	h := sha1.New()
	h.Write([]byte(s))

	hash := h.Sum(nil)

	return fmt.Sprintf("%x", hash)
}
1174866
func MakeHash(newHash []byte) (Hash, error) {
	nhlen := len(newHash)
	if nhlen != HashSize {
		return Hash{}, fmt.Errorf("invalid hash length of %v, want %v",
			nhlen, HashSize)
	}

	var hash Hash
	copy(hash[:], newHash)

	return hash, nil
}
1370670
func IsHash(str string, algorithm string) bool {
	len := "0"
	algo := strings.ToLower(algorithm)

	if algo == "crc32" || algo == "crc32b" {
		len = "8"
	} else if algo == "md5" || algo == "md4" || algo == "ripemd128" || algo == "tiger128" {
		len = "32"
	} else if algo == "sha1" || algo == "ripemd160" || algo == "tiger160" {
		len = "40"
	} else if algo == "tiger192" {
		len = "48"
	} else if algo == "sha256" {
		len = "64"
	} else if algo == "sha384" {
		len = "96"
	} else if algo == "sha512" {
		len = "128"
	} else {
		return false
	}

	return Matches(str, "^[a-f0-9]{"+len+"}$")
}
1178443
func Hash(fieldVals []interface{}) uint64 {
	if len(fieldVals) == 0 {
		// Avoid allocating the hasher if there are no fieldVals
		return 0
	}
	h := fnv.New64a()

	for _, v := range fieldVals {
		switch v := v.(type) {
		case string:
			h.Write([]byte(v))
		case int64:
			b := [8]byte{}
			for i := 0; i < 8; i++ {
				b[i] = byte(v & 0xFF)
				v >>= 8
			}
			h.Write(b[:])
		case bool:
			if v {
				h.Write([]byte{1})
			} else {
				h.Write([]byte{0})
			}
		}
	}
	return h.Sum64()
}
1339298
func extractSubTangleMilestoneHash(data []byte) (string, error) {
	firstColonIndex := bytes.Index(data, colonSep[:])
	if firstColonIndex == -1 {
		return "", errors.Wrap(ErrNoLatestSolidSubtangleInfo, "unable to find hash")
	}
	leadingQuoteIndex := bytes.Index(data[firstColonIndex+1:], quoteSep[:])
	if leadingQuoteIndex == -1 {
		return "", errors.Wrap(ErrNoLatestSolidSubtangleInfo, "unable to find leading quote in hash search")
	}
	leadingQuoteIndex = firstColonIndex + 1 + leadingQuoteIndex
	endingQuoteIndex := bytes.Index(data[leadingQuoteIndex+1:], quoteSep[:])
	if endingQuoteIndex == -1 {
		return "", errors.Wrap(ErrNoLatestSolidSubtangleInfo, "unable to find ending quote in hash search")
	}
	endingQuoteIndex = leadingQuoteIndex + 1 + endingQuoteIndex
	return string(data[leadingQuoteIndex+1 : endingQuoteIndex]), nil
}
720322
func (v *Libravatar) genHash(email *mail.Address, openid *url.URL) string {
	if email != nil {
		email.Address = strings.ToLower(strings.TrimSpace(email.Address))
		sum := md5.Sum([]byte(email.Address))
		return fmt.Sprintf("%x", sum)
	} else if openid != nil {
		openid.Scheme = strings.ToLower(openid.Scheme)
		openid.Host = strings.ToLower(openid.Host)
		sum := sha256.Sum256([]byte(openid.String()))
		return fmt.Sprintf("%x", sum)
	}
	// panic, because this should not be reachable
	panic("Neither Email or OpenID set")
}
43045
func sha1Hash(slices [][]byte) []byte {
	hsha1 := sha1.New()
	for _, slice := range slices {
		hsha1.Write(slice)
	}
	return hsha1.Sum(nil)
}
370965
func ToHash(s []byte) Hash {
	if len(s) == 0 || len(s) > _Hash_maxLen {
		return 0
	}
	h := uint32(_Hash_hash0)
	for i := 0; i < len(s); i++ {
		h ^= uint32(s[i])
		h *= 16777619
	}
	if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
		t := _Hash_text[i>>8 : i>>8+i&0xff]
		for i := 0; i < len(s); i++ {
			if t[i] != s[i] {
				goto NEXT
			}
		}
		return i
	}
NEXT:
	if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
		t := _Hash_text[i>>8 : i>>8+i&0xff]
		for i := 0; i < len(s); i++ {
			if t[i] != s[i] {
				return 0
			}
		}
		return i
	}
	return 0
}
139011
func (v Var) Hash() int {
	h := xxhash.ChecksumString64S(string(v), hashSeed0)
	return int(h)
}
664557
func (typedData *TypedData) TypeHash(primaryType string) hexutil.Bytes {
	return crypto.Keccak256(typedData.EncodeType(primaryType))
}
83912
def _set_latlng_from_geohash
      geohash = self.geohash
      if geohash.nil?
        self.lat = self.lng = nil
        return
      end
      _validate_geohash(geohash)

      geohash_i = _geohash_to_int(geohash)
      lat,lng = _deinterleave_bits(geohash_i)
      lat = lat * 180.0 / (1<<32) -  90.0
      lng = lng * 360.0 / (1<<32) - 180.0
      self.lat = lat
      self.lng = lng
      return
    end
81327
func MMH3Hash(value string) uint64 {
	h1, _ := mmh3.Hash128(value)
	return h1
}
439246
func (h *HLL) AddHash(hash uint64) {
	switch h.format {
	case NORMAL:
		h.addNormal(hash)
	case SPARSE:
		h.addSparse(hash)
	}
}