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 .