IMac mac = MacFactory.getInstance("HMAC-SHA-160"); HashMap attributes = new HashMap(); attributes.put(IMac.MAC_KEY_MATERIAL, key_bytes); attributes.put(IMac.TRUNCATED_SIZE, new Integer(12)); mac.init(attributes); mac.update(input, 0, input.length); byte[] result = mac.digest();