Returns the segment that should be used for key with given hash

@param hash the hash code for the key
@return the segment
325313
private LinkedHashMapSegment<K, V> segmentFor(int hash) {
        int h = hash(hash);
        return segments[(h >>> segmentShift) & segmentMask];
    }
1121924
public long[] decode(String hash){
    long[] ret = {};

    if(hash.equals(""))
      return ret;

    return this._decode(hash, this.alphabet);
  }
517158
@SuppressWarnings("unchecked")
    static final <K,V> HashEntry<K,V> entryForHash(Segment<K,V> seg, int h) {
        HashEntry<K,V>[] tab;
        return (seg == null || (tab = seg.table) == null) ? null :
            (HashEntry<K,V>) UNSAFE.getObjectVolatile
            (tab, ((long)(((tab.length - 1) & h)) << TSHIFT) + TBASE);
    }
320625
public String hash(String key) {
        if (digester != null) {
            byte[] bytes = digester.digest(key.getBytes());
            return bytesToHexString(bytes);
        } else {
            return Integer.toHexString(key.hashCode());
        }
    }
874551
public MethodHash computeHash(Method method) {
        final MessageDigest digest = Util.getMD5Digest();

        byte[] code;
        if (method.getCode() == null || method.getCode().getCode() == null) {
            code = new byte[0];
        } else {
            code = method.getCode().getCode();
        }

        BytecodeScanner.Callback callback = (opcode, index) -> digest.update((byte) opcode);

        BytecodeScanner bytecodeScanner = new BytecodeScanner();
        bytecodeScanner.scan(code, callback);

        hash = digest.digest();

        return this;
    }
664921
public static int hashBytesByWords(MemorySegment segment, int offset, int lengthInBytes) {
		return hashBytesByWords(segment, offset, lengthInBytes, DEFAULT_SEED);
	}
62835
public static int hashBytes(MemorySegment segment, int offset, int lengthInBytes) {
		return hashBytes(segment, offset, lengthInBytes, DEFAULT_SEED);
	}
870079
def string_hash(hash)
      hash.map { |k, v| [k.to_s, v.to_s] }.to_h
    end
408108
@SuppressWarnings("unchecked")
    private Segment<K,V> ensureSegment(int k) {
        final Segment<K,V>[] ss = this.segments;
        long u = (k << SSHIFT) + SBASE; // raw offset
        Segment<K,V> seg;
        if ((seg = (Segment<K,V>)UNSAFE.getObjectVolatile(ss, u)) == null) {
            Segment<K,V> proto = ss[0]; // use segment 0 as prototype
            int cap = proto.table.length;
            float lf = proto.loadFactor;
            int threshold = (int)(cap * lf);
            HashEntry<K,V>[] tab = new HashEntry[cap];
            if ((seg = (Segment<K,V>)UNSAFE.getObjectVolatile(ss, u))
                == null) { // recheck
                Segment<K,V> s = new Segment<K,V>(lf, threshold, tab);
                while ((seg = (Segment<K,V>)UNSAFE.getObjectVolatile(ss, u))
                       == null) {
                    if (UNSAFE.compareAndSwapObject(ss, u, null, seg = s)) {
                      break;
                    }
                }
            }
        }
        return seg;
    }
212141
public static String asHex (byte[] hash) {
		StringBuilder buf = new StringBuilder(hash.length * 2);
		int i;

		for (i = 0; i < hash.length; i++) {
			if (((int) hash[i] & 0xff) < 0x10) 
				buf.append("0");

			buf.append(Long.toString((int) hash[i] & 0xff, 16));
		}

		return buf.toString();
	}
127529
@Deprecated
  private static ArrayList<FrequencyTableEntry> hashToFreqEntries(
      HashMap<String, ArrayList<Integer>> hash) {
    ArrayList<FrequencyTableEntry> res = new ArrayList<FrequencyTableEntry>();
    for (Entry<String, ArrayList<Integer>> e : hash.entrySet()) {
      char[] payload = e.getKey().toCharArray();
      int frequency = e.getValue().size();
      for (Integer i : e.getValue()) {
        res.add(new FrequencyTableEntry(i, payload.clone(), frequency));
      }
    }
    return res;
  }
263687
final Entry<K, V> getEntry(Object key) {
	int hash = (key == null) ? 0 : hash(key);
	for (Entry<K, V> e = table[indexFor(hash, table.length)]; e != null; e = e.next) {
	    if (e.hash == hash && ((e.key) == key || (key != null && key.equals(e.key)))) return e;
	}
	return null;
    }
1339341
private String getHash() {
        try {
            Node contentNode = getContextNode();
            Property data = contentNode.getProperty(Property.JCR_DATA);
            Binary bin = (Binary) data.getBinary();
            return String.format("{%s}%s", HASH_ALGORITHM, bin.getHexHash());
        } catch (RepositoryException e) {
            return "";
        }
    }
919062
private boolean parseEscapedHash(String hash) {
		if (StringUtils.isEmpty(hash))
			return false;

		hashEscaped = true;
		int maxPage = -1;

		try {
			for (String str : hash.split("&")) {
				int idx = str.indexOf("=");
				if (idx <= 0)
					continue;

				String name = URLDecoder.decode(str.substring(0, idx), "UTF-8");
				String value = URLDecoder.decode(str.substring(idx + 1),
						"UTF-8");

				if (name.indexOf("[") == -1) {
					getHashParams("root", true).put(name, value);
					continue;
				}

				Matcher m = P_GROUP_PARAM.matcher(name);
				if (m.find()) {
					getHashParams(m.group(1), true).put(m.group(2), value);
					continue;
				}

				m = P_PAGE_URL.matcher(name);
				if (m.find()) {
					int page = Integer.parseInt(m.group(1));

					if (page > maxPage)
						topPageParams = null;

					if (page >= maxPage) {
						maxPage = page;
						topPageUrl = value;
						continue;
					}
				}

				m = P_PAGE_PARAMETER.matcher(name);
				if (m.find()) {
					int page = Integer.parseInt(m.group(1));

					if (page > maxPage) {
						topPageUrl = null;
						topPageParams = null;
					}

					if (page >= maxPage) {
						if (topPageParams == null)
							topPageParams = new HashMap<String, String>();
						topPageParams.put(m.group(2), value);
						continue;
					}
				}

				// 不支持的参数，忽略不处理
				System.err.println("Unsupported escaped hash parameter name: "
						+ name + ", value: " + value);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return true;
	}
504717
def _get_hash():
    '''
    
    '''
    # Using bitmask to emulate rollover behavior of C unsigned 32 bit int
    bitmask = 0xffffffff
    h = 0

    for i in bytearray(salt.utils.stringutils.to_bytes(__grains__['id'])):
        h = (h + i) & bitmask
        h = (h + (h << 10)) & bitmask
        h = (h ^ (h >> 6)) & bitmask

    h = (h + (h << 3)) & bitmask
    h = (h ^ (h >> 11)) & bitmask
    h = (h + (h << 15)) & bitmask

    return (h & (_HASH_SIZE - 1)) & bitmask
510944
public function getSegmentHashesByIdSite()
    {
        //Get a list of hashes of all segments that exist now
        $sql = "SELECT DISTINCT definition, enable_only_idsite FROM " . Common::prefixTable('segment')
            . " WHERE deleted = 0";
        $rows = Db::fetchAll($sql);
        $segmentHashes = array();
        foreach ($rows as $row) {
            $idSite = (int)$row['enable_only_idsite'];
            if (! isset($segmentHashes[$idSite])) {
                $segmentHashes[$idSite] = array();
            }
            $segmentHashes[$idSite][] = Segment::getSegmentHash($row['definition']);
        }

        return $segmentHashes;
    }
1131032
@Nullable
    static String shaHashInput(@Nullable String toHash) {
        if (StripeTextUtils.isBlank(toHash)) {
            return null;
        }

        try {
            final MessageDigest digest = MessageDigest.getInstance("SHA-1");
            final byte[] bytes = toHash.getBytes("UTF-8");
            digest.update(bytes, 0, bytes.length);
            return bytesToHex(digest.digest());
        } catch (NoSuchAlgorithmException noSuchAlgorithm) {
            return null;
        } catch (UnsupportedEncodingException unsupportedCoding) {
            return null;
        }
    }