protected byte[] sign(byte[] data, byte[] key,
            SigningAlgorithm algorithm) throws SdkClientException {
        try {
            Mac mac = algorithm.getMac();
            mac.init(new SecretKeySpec(key, algorithm.toString()));
            return mac.doFinal(data);
        } catch (Exception e) {
            throw new SdkClientException(
                    "Unable to calculate a request signature: "
                            + e.getMessage(), e);
        }
    }
Computes an RFC 2104-compliant HMAC signature for an array of bytes and
returns the result as a Base64 encoded string.
aws-java-sdk-core/src/main/java/com/amazonaws/auth/AbstractAWSSigner.java