private byte [ ] calculateHmacSHA256 ( String data , byte [ ] key ) throws NoSuchAlgorithmException , InvalidKeyException , UnsupportedEncodingException { Mac mac = Mac . getInstance ( HMAC_ALGORITHM ) ; mac . init ( new SecretKeySpec ( key , HMAC_ALGORITHM ) ) ; return mac . doFinal ( data . getBytes ( ENCODING ) ) ; }
Calculates the keyed - hash message authentication code for the data string .