Hashes the binary data using the SHA-256 algorithm.

@param data
The binary data to hash.

@return The hashed bytes from the specified data.

@throws SdkClientException
If the hash cannot be computed.
497814
public byte[] hash(byte[] data) throws SdkClientException {
        try {
            MessageDigest md =  getMessageDigestInstance();
            md.update(data);
            return md.digest();
        } catch (Exception e) {
            throw new SdkClientException(
                    "Unable to compute hash while signing request: "
                            + e.getMessage(), e);
        }
    }
147896
@Override
	public byte[] calculateSHA384HMAC(byte[] data, int offset, int length,
			byte[] aKey) {
		return BCHmacAdapter.hmac(data, offset, length, aKey, "HmacSHA384");
	}
14686
public static byte[] md2Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return md2Hash(data.getBytes(charset));
	}
704078
def hash_data(data, blocksize=65536):
    "
    data = pickle.dumps(data)

    hasher = hashlib.sha1()
    hasher.update(data)

    return hasher.hexdigest()
1045028
public static byte[] sha256X16(String data, String encoding) {
		byte[] bytes = sha256(data, encoding);
		StringBuilder sha256StrBuff = new StringBuilder();
		for (int i = 0; i < bytes.length; i++) {
			if (Integer.toHexString(0xFF & bytes[i]).length() == 1) {
				sha256StrBuff.append("0").append(
						Integer.toHexString(0xFF & bytes[i]));
			} else {
				sha256StrBuff.append(Integer.toHexString(0xFF & bytes[i]));
			}
		}
		try {
			return sha256StrBuff.toString().getBytes(encoding);
		} catch (UnsupportedEncodingException e) {
			LogUtil.writeErrorLog(e.getMessage(), e);
			return null;
		}
	}
837676
public static String sha256(final String data) {
        return digest(MessageDigestAlgorithms.SHA_256, data.getBytes(StandardCharsets.UTF_8));
    }
82904
public static int hash32(byte[] data, int length, int seed) {
        int hash = seed;
        final int nblocks = length >> 2;

        // body
        for (int i = 0; i < nblocks; i++) {
            int i_4 = i << 2;
            int k = (data[i_4] & 0xff)
                | ((data[i_4 + 1] & 0xff) << 8)
                | ((data[i_4 + 2] & 0xff) << 16)
                | ((data[i_4 + 3] & 0xff) << 24);

            // mix functions
            k *= C1_32;
            k = Integer.rotateLeft(k, R1_32);
            k *= C2_32;
            hash ^= k;
            hash = Integer.rotateLeft(hash, R2_32) * M_32 + N_32;
        }

        // tail
        int idx = nblocks << 2;
        int k1 = 0;
        switch (length - idx) {
            case 3:
                k1 ^= data[idx + 2] << 16;
            case 2:
                k1 ^= data[idx + 1] << 8;
            case 1:
                k1 ^= data[idx];

                // mix functions
                k1 *= C1_32;
                k1 = Integer.rotateLeft(k1, R1_32);
                k1 *= C2_32;
                hash ^= k1;
        }

        // finalization
        hash ^= length;
        hash ^= (hash >>> 16);
        hash *= 0x85ebca6b;
        hash ^= (hash >>> 13);
        hash *= 0xc2b2ae35;
        hash ^= (hash >>> 16);

        return hash;
    }
643170
public static byte[] md5Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return md5Hash(data.getBytes(charset));
	}
1239261
public static byte[] sha1Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return sha1Hash(data.getBytes(charset));
	}
712531
function(key, data) {
        var shaObj = new Sha('SHA-256', 'TEXT');
        shaObj.setHMACKey(key, 'TEXT');
        shaObj.update(data);
        return shaObj.getHMAC('HEX');
    }
958569
public static byte[] sha224Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return sha224Hash(data.getBytes(charset));
	}
929525
public static int hashBytes(byte[] bytes, int offset, int length) {
    int hash = 1;
    for (int i = offset; i < offset + length; i++) {
      hash = (31 * hash) + bytes[i];
    }
    return hash;
  }
649173
public static byte[] hashToBytes(final char[] data, final long seed) {
    if ((data == null) || (data.length == 0)) {
      return null;
    }
    return toByteArray(hash(data, seed));
  }
1088133
public static byte[] toBytes(final long data) {
    return new byte[]{
      (byte) (data >> 56 & 0xFF),
      (byte) (data >> 48 & 0xFF),
      (byte) (data >> 40 & 0xFF),
      (byte) (data >> 32 & 0xFF),
      (byte) (data >> 24 & 0xFF),
      (byte) (data >> 16 & 0xFF),
      (byte) (data >> 8 & 0xFF),
      (byte) (data & 0xFF)};
  }
20449
public static int hash(byte[] data, int offset, int length, int seed) {
	    return hash(ByteBuffer.wrap(data, offset, length), seed);
	  }
665150
public static byte[] decode(byte[] data)
	{
		if (data.length == 0)
		{
			return data;
		}
		int lastRealDataIndex = data.length - 1;
		while (data[lastRealDataIndex] == equalSign)
		{
			lastRealDataIndex--;
		}
		// original data digit is 8 bits long, but base64 digit is 6 bits long
		int padBytes = data.length - 1 - lastRealDataIndex;
		int byteLength = data.length * 6 / 8 - padBytes;
		byte[] result = new byte[byteLength];
		// Each 4 bytes of input (encoded) we end up with 3 bytes of output
		int dataIndex = 0;
		int resultIndex = 0;
		int allBits = 0;
		// how many result chunks we can process before getting to pad bytes
		int resultChunks = (lastRealDataIndex + 1) / 4;
		for (int i = 0; i < resultChunks; i++)
		{
			allBits = 0;
			// Loop 4 times gathering input bits (4 * 6 = 24)
			for (int j = 0; j < 4; j++)
			{
				allBits = allBits << 6 | decodeDigit(data[dataIndex++]);
			}
			// Loop 3 times generating output bits (3 * 8 = 24)
			for (int j = resultIndex + 2; j >= resultIndex; j--)
			{
				result[j] = (byte) (allBits & 0xff); // Bottom 8 bits
				allBits = allBits >>> 8;
			}
			resultIndex += 3; // processed 3 result bytes
		}
		// Now we do the extra bytes in case the original (non-encoded) data
		// was not multiple of 3 bytes
		switch (padBytes)
		{
			case 1:
				// 1 pad byte means 3 (4-1) extra Base64 bytes of input, 18
				// bits, of which only 16 are meaningful
				// Or: 2 bytes of result data
				allBits = 0;
				// Loop 3 times gathering input bits
				for (int j = 0; j < 3; j++)
				{
					allBits = allBits << 6 | decodeDigit(data[dataIndex++]);
				}
				// NOTE - The code below ends up being equivalent to allBits =
				// allBits>>>2
				// But we code it in a non-optimized way for clarity
				// The 4th, missing 6 bits are all 0
				allBits = allBits << 6;
				// The 3rd, missing 8 bits are all 0
				allBits = allBits >>> 8;
				// Loop 2 times generating output bits
				for (int j = resultIndex + 1; j >= resultIndex; j--)
				{
					result[j] = (byte) (allBits & 0xff); // Bottom 8
					// bits
					allBits = allBits >>> 8;
				}
				break;
			case 2:
				// 2 pad bytes mean 2 (4-2) extra Base64 bytes of input, 12 bits
				// of data, of which only 8 are meaningful
				// Or: 1 byte of result data
				allBits = 0;
				// Loop 2 times gathering input bits
				for (int j = 0; j < 2; j++)
				{
					allBits = allBits << 6 | decodeDigit(data[dataIndex++]);
				}
				// NOTE - The code below ends up being equivalent to allBits =
				// allBits>>>4
				// But we code it in a non-optimized way for clarity
				// The 3rd and 4th, missing 6 bits are all 0
				allBits = allBits << 6;
				allBits = allBits << 6;
				// The 3rd and 4th, missing 8 bits are all 0
				allBits = allBits >>> 8;
				allBits = allBits >>> 8;
				result[resultIndex] = (byte) (allBits & 0xff); // Bottom
				// 8
				// bits
				break;
		}
		return result;
	}
575919
function sha256(data) {
    if (!data.byteLength) {
        return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));
    }
    if (subtle) {
        return subtle.digest({ name: 'SHA-256' }, data);
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var sha = nodeCrypto.createHash('sha256');
            var hash = sha.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));
    }
}