Gets the hash value of the given queue and the given algorithm.

@see <a href="https://en.wikipedia.org/wiki/Merkle_tree">wikipedia Merkle tree</a>

@param hashQueue
the hash queue
@param algorithm
the algorithm
@return the merkle root tree
191124
public static byte[] getMerkleRootHash(Queue<byte[]> hashQueue,
		@NonNull HashAlgorithm algorithm)
	{
		while (hashQueue.size() > 1)
		{
			byte[] hashValue = ArrayUtils.addAll(hashQueue.poll(), hashQueue.poll());
			switch (algorithm)
			{
				case SHA1 :
					hashQueue.add(DigestUtils.sha1(hashValue));
				case SHA256 :
					hashQueue.add(DigestUtils.sha256(hashValue));
				case SHA384 :
					hashQueue.add(DigestUtils.sha384(hashValue));
				case SHA512 :
					hashQueue.add(DigestUtils.sha512(hashValue));
				case SHA_1 :
					hashQueue.add(DigestUtils.sha1(hashValue));
				case SHA_256 :
					hashQueue.add(DigestUtils.sha256(hashValue));
				case SHA_384 :
					hashQueue.add(DigestUtils.sha384(hashValue));
				case SHA_512 :
					hashQueue.add(DigestUtils.sha512(hashValue));
				default :
					hashQueue.add(DigestUtils.sha256(hashValue));
			}
		}
		return hashQueue.poll();
	}
942183
private String getDigestHex(String algorithm, String key) {
        if (algorithm.equals("md5")) {
            return DigestUtils.md5Hex(key);
        } else if (algorithm.equals("sha")) {
            return DigestUtils.shaHex(key);
        }
        
        throw new CitrusRuntimeException("Unsupported digest algorithm: " + algorithm);
    }
561959
public static String getAlgorithmAfterWith(String algorithm) {
		Assert.notNull(algorithm, "algorithm must be not null !");
		int indexOfWith = StrUtil.lastIndexOfIgnoreCase(algorithm, "with");
		if (indexOfWith > 0) {
			algorithm = StrUtil.subSuf(algorithm, indexOfWith + "with".length());
		}
		if ("ECDSA".equalsIgnoreCase(algorithm) || "SM2".equalsIgnoreCase(algorithm)) {
			algorithm = "EC";
		}
		return algorithm;
	}
1341285
public static String getFingerprint(byte[] encoded, String algorithm)
			throws SshException {

		Digest md5 = (Digest) ComponentManager.getInstance().supportedDigests()
				.getInstance(algorithm);

		md5.putBytes(encoded);

		byte[] digest = md5.doFinal();

		StringBuffer buf = new StringBuffer();
		int ch;
		for (int i = 0; i < digest.length; i++) {
			ch = digest[i] & 0xFF;
			if (i > 0) {
				buf.append(':');
			}
			buf.append(HEX[(ch >>> 4) & 0x0F]);
			buf.append(HEX[ch & 0x0F]);
		}

		return buf.toString();
	}
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 "";
        }
    }
440450
public final int hash(ByteBuffer buf, int seed) {
    final int hash = hash(buf, buf.position(), buf.remaining(), seed);
    buf.position(buf.limit());
    return hash;
  }
1289573
public static int hash(MemorySegment[] segments, int offset, int numBytes) {
		if (inFirstSegment(segments, offset, numBytes)) {
			return MurmurHashUtil.hashBytes(segments[0], offset, numBytes);
		} else {
			return hashMultiSeg(segments, offset, numBytes);
		}
	}
1122203
public String getHashForLine(int line) {
    if (line > 0 && line <= hashes.size()) {
      return Strings.nullToEmpty(hashes.get(line - 1));
    }
    return "";
  }
930954
public HashMap getAllXmitQueuePoints()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.entry(tc, "getAllXmitQueuePoints");
      SibTr.exit(tc, "getAllXmitQueuePoints", _xmitQueuePoints);
    }

    return _xmitQueuePoints;
  }
684173
private byte[] generateDeterministicHash(
			StreamNode node,
			Hasher hasher,
			Map<Integer, byte[]> hashes,
			boolean isChainingEnabled,
			StreamGraph streamGraph) {

		// Include stream node to hash. We use the current size of the computed
		// hashes as the ID. We cannot use the node's ID, because it is
		// assigned from a static counter. This will result in two identical
		// programs having different hashes.
		generateNodeLocalHash(hasher, hashes.size());

		// Include chained nodes to hash
		for (StreamEdge outEdge : node.getOutEdges()) {
			if (isChainable(outEdge, isChainingEnabled, streamGraph)) {

				// Use the hash size again, because the nodes are chained to
				// this node. This does not add a hash for the chained nodes.
				generateNodeLocalHash(hasher, hashes.size());
			}
		}

		byte[] hash = hasher.hash().asBytes();

		// Make sure that all input nodes have their hash set before entering
		// this loop (calling this method).
		for (StreamEdge inEdge : node.getInEdges()) {
			byte[] otherHash = hashes.get(inEdge.getSourceId());

			// Sanity check
			if (otherHash == null) {
				throw new IllegalStateException("Missing hash for input node "
						+ streamGraph.getSourceVertex(inEdge) + ". Cannot generate hash for "
						+ node + ".");
			}

			for (int j = 0; j < hash.length; j++) {
				hash[j] = (byte) (hash[j] * 37 ^ otherHash[j]);
			}
		}

		if (LOG.isDebugEnabled()) {
			String udfClassName = "";
			if (node.getOperator() instanceof AbstractUdfStreamOperator) {
				udfClassName = ((AbstractUdfStreamOperator<?, ?>) node.getOperator())
						.getUserFunction().getClass().getName();
			}

			LOG.debug("Generated hash '" + byteToHexString(hash) + "' for node " +
					"'" + node.toString() + "' {id: " + node.getId() + ", " +
					"parallelism: " + node.getParallelism() + ", " +
					"user function: " + udfClassName + "}");
		}

		return hash;
	}
1324318
private static byte[] hashTemplate(byte[] data, String algorithm) {
        if (data == null || data.length <= 0) return null;
        try {
            MessageDigest md = MessageDigest.getInstance(algorithm);
            md.update(data);
            return md.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
941636
public static SshKeyPair generateKeyPair(String algorithm, int bits)
			throws IOException, SshException {

		if (!SSH2_RSA.equalsIgnoreCase(algorithm)
				&& !SSH2_DSA.equalsIgnoreCase(algorithm)) {
			throw new IOException(algorithm
					+ " is not a supported key algorithm!");
		}

		SshKeyPair pair = new SshKeyPair();

		if (SSH2_RSA.equalsIgnoreCase(algorithm)) {
			pair = ComponentManager.getInstance().generateRsaKeyPair(bits);
		} else {
			pair = ComponentManager.getInstance().generateDsaKeyPair(bits);
		}

		return pair;
	}
798265
public static int singleWordWangJenkinsHash(Object k) {
        int h = k.hashCode();

        h += (h <<  15) ^ 0xffffcd7d;
        h ^= (h >>> 10);
        h += (h <<   3);
        h ^= (h >>>  6);
        h += (h <<   2) + (h << 14);
        return h ^ (h >>> 16);
    }
1032776
private Sha256Hash recursiveExtractHashes(int height, int pos, ValuesUsed used, List<Sha256Hash> matchedHashes) throws VerificationException {
        if (used.bitsUsed >= matchedChildBits.length*8) {
            // overflowed the bits array - failure
            throw new VerificationException("PartialMerkleTree overflowed its bits array");
        }
        boolean parentOfMatch = checkBitLE(matchedChildBits, used.bitsUsed++);
        if (height == 0 || !parentOfMatch) {
            // if at height 0, or nothing interesting below, use stored hash and do not descend
            if (used.hashesUsed >= hashes.size()) {
                // overflowed the hash array - failure
                throw new VerificationException("PartialMerkleTree overflowed its hash array");
            }
            Sha256Hash hash = hashes.get(used.hashesUsed++);
            if (height == 0 && parentOfMatch) // in case of height 0, we have a matched txid
                matchedHashes.add(hash);
            return hash;
        } else {
            // otherwise, descend into the subtrees to extract matched txids and hashes
            byte[] left = recursiveExtractHashes(height - 1, pos * 2, used, matchedHashes).getBytes(), right;
            if (pos * 2 + 1 < getTreeWidth(transactionCount, height-1)) {
                right = recursiveExtractHashes(height - 1, pos * 2 + 1, used, matchedHashes).getBytes();
                if (Arrays.equals(right, left))
                    throw new VerificationException("Invalid merkle tree with duplicated left/right branches");
            } else {
                right = left;
            }
            // and combine them before returning
            return combineLeftRight(left, right);
        }
    }
1197277
public static int hash(int hash, String s) {
    if (s == null) {
      return hash;
    }
    // similar to Arrays.hashCode
    return s.indexOf('%') < 0 ? 31 * hash + s.hashCode() : normalizedHash(hash, s);
  }
1340781
public static int hash(int hashCode, int level) {
		final int rotation = level * 11;
		int code = Integer.rotateLeft(hashCode, rotation);
		return code >= 0 ? code : -(code + 1);
	}
946360
private function getHashAlgorithm(string $algorithm) : string
    {
        switch ($algorithm) {
            case Algorithms::SHA256:
                return 'sha256';
            case Algorithms::SHA384:
                return 'sha384';
            case Algorithms::SHA512:
                return 'sha512';
            default:
                throw new InvalidArgumentException("Algorithm \"$algorithm\" is not a hash algorithm");
        }
    }