Here you can find the source of hmacSha1(byte[] data, byte[] key)
public static byte[] hmacSha1(byte[] data, byte[] key)
//package com.java2s; //License from project: Apache License import java.security.GeneralSecurityException; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class Main { /**// w w w . ja v a 2s. com * Do HMAC-SHA1. * * @return byte[] as result. */ public static byte[] hmacSha1(byte[] data, byte[] key) { SecretKey skey = new SecretKeySpec(key, "HmacSHA1"); Mac mac; try { mac = Mac.getInstance("HmacSHA1"); mac.init(skey); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } mac.update(data); return mac.doFinal(); } }