Code example for Mac

Methods: doFinalinit

    } catch (InvalidKeyException ike) {
      throw new IllegalArgumentException("Invalid key to HMAC computation", 
    return mac.doFinal(identifier);
   * Convert the byte[] to a secret key 
   * @param key the byte[] to create a secret key from 
   * @return the secret key 
  protected static SecretKey createSecretKey(byte[] key) {
    return new SecretKeySpec(key, DEFAULT_HMAC_ALGORITHM);
Connect your IDE to all the code out there  Get Codota for Java