code: private static byte[] hmacTemplate(byte[] data, byte[] key, String algorithm) {
          if (data == null || data.length == 0 || key == null || key.length == 0) return null;
          try {
              SecretKeySpec secretKey = new SecretKeySpec(key, algorithm);
              Mac           mac       = Mac.getInstance(algorithm);
              mac.init(secretKey);
              return mac.doFinal(data);
          } catch (InvalidKeyException | NoSuchAlgorithmException e) {
              e.printStackTrace();
              return null;
          }
      }
docs: Hmac加密模板
  
  @param data      数据
  @param key       秘钥
  @param algorithm 加密算法
  @return 密文字节数组