public static byte[] sumHmac(byte[] key,byte[] data) throws NoSuchAlgorithmException, InvalidKeyException {
  Mac mac=Mac.getInstance("HmacSHA256");
  mac.init(new SecretKeySpec(key,"HmacSHA256"));
  mac.update(data);
  return mac.doFinal();
}

public static byte [ ] sumHmac ( byte [ ] key , byte [ ] data ) throws NoSuchAlgorithmException , InvalidKeyException { Mac mac = Mac . getInstance ( "HmacSHA256" ) ; mac . init ( new SecretKeySpec ( key , "HmacSHA256" ) ) ; mac . update ( data ) ; return mac . doFinal ( ) ; }
returns hmacsha256 digest of given key and data .
