Here you can find the source of hmacSha1(SecretKeySpec signingKey, byte[]... data)
public static byte[] hmacSha1(SecretKeySpec signingKey, byte[]... data)
//package com.java2s; //License from project: Open Source License import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class Main { private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; public static byte[] hmacSha1(SecretKeySpec signingKey, byte[]... data) { Mac mac = buildHmacSha1(signingKey); return hmacSha1(mac, data); }/*from w ww . j av a 2 s . c o m*/ public static byte[] hmacSha1(Mac mac, byte[]... data) { for (int i = 0; i < data.length - 1; i++) { mac.update(data[i]); } byte[] hash = mac.doFinal(data[data.length - 1]); return hash; } public static byte[] hmacSha1(SecretKeySpec signingKey, byte[] buffer, int offset, int length) { Mac mac = buildHmacSha1(signingKey); mac.update(buffer, offset, length); byte[] hash = mac.doFinal(); return hash; } public static Mac buildHmacSha1(SecretKey key) { Mac mac = getHmacSha1(); try { mac.init(key); } catch (InvalidKeyException e) { throw new IllegalStateException("Unexpected encryption error", e); } return mac; } private static Mac getHmacSha1() { return getMac(HMAC_SHA1_ALGORITHM); } private static Mac getMac(String algorithm) { try { Mac digest = Mac.getInstance(algorithm); return digest; } catch (NoSuchAlgorithmException e) { // should not happen throw new IllegalStateException("Could not find Mac algorithm: " + algorithm, e); } } }