protected byte[] hash(InputStream input) throws SdkClientException {
        try {
            MessageDigest md = getMessageDigestInstance();
            @SuppressWarnings("resource")
            DigestInputStream digestInputStream = new SdkDigestInputStream(
                    input, md);
            byte[] buffer = new byte[1024];
            while (digestInputStream.read(buffer) > -1)
                ;
            return digestInputStream.getMessageDigest().digest();
        } catch (Exception e) {
            throw new SdkClientException(
                    "Unable to compute hash while signing request: "
                            + e.getMessage(), e);
        }
    }
Hashes the string contents (assumed to be UTF-8) using the SHA-256
algorithm.

@param text
           The string to hash.

@return The hashed bytes from the specified string.

@throws SdkClientException
            If the hash cannot be computed.
aws-java-sdk-core/src/main/java/com/amazonaws/auth/AbstractAWSSigner.java