public byte[] calculateHMAC_SHA256(byte[] input,byte[] key,int length){
  byte[] output=null;
  try {
    hmacSHA256.init(new SecretKeySpec(key,0,length,"HmacSHA256"));
    output=hmacSHA256.doFinal(input);
  }
 catch (  InvalidKeyException e) {
    log.error("Invalid key",e);
  }
  return output;
}

public byte [ ] calculateHMAC_SHA256 ( byte [ ] input , byte [ ] key , int length ) { byte [ ] output = null ; try { hmacSHA256 . init ( new SecretKeySpec ( key , 0 , length , "HmacSHA256" ) ) ; output = hmacSHA256 . doFinal ( input ) ; } catch ( InvalidKeyException e ) { log . error ( "Invalid key" , e ) ; } return output ; }
calculates an hmac sha256 hash using a set key length .
