@Test public void testGzip() throws IOException { byte[] input1 = "Hello Hello Hello".getBytes("UTF8"); byte[] output1 = GzipEncryptor.gzip(input1); byte[] expectedOutput1 = CryptoUnitUtils.hexToBytes("1f8b0800000000000000f348cdc9c957f0409000a91a078c11000000"); assertArrayEquals(expectedOutput1, output1); }
static byte[] gzip(byte[] input) throws IOException { ByteArrayOutputStream zipBytes = new ByteArrayOutputStream(input.length); try (GZIPOutputStream out = new GZIPOutputStream(zipBytes);) { out.write(input, 0, input.length); } return zipBytes.toByteArray(); }
GzipEncryptor implements BytesEncryptor { static byte[] gzip(byte[] input) throws IOException { ByteArrayOutputStream zipBytes = new ByteArrayOutputStream(input.length); try (GZIPOutputStream out = new GZIPOutputStream(zipBytes);) { out.write(input, 0, input.length); } return zipBytes.toByteArray(); } }
GzipEncryptor implements BytesEncryptor { static byte[] gzip(byte[] input) throws IOException { ByteArrayOutputStream zipBytes = new ByteArrayOutputStream(input.length); try (GZIPOutputStream out = new GZIPOutputStream(zipBytes);) { out.write(input, 0, input.length); } return zipBytes.toByteArray(); } GzipEncryptor(BytesEncryptor delegate); }
GzipEncryptor implements BytesEncryptor { static byte[] gzip(byte[] input) throws IOException { ByteArrayOutputStream zipBytes = new ByteArrayOutputStream(input.length); try (GZIPOutputStream out = new GZIPOutputStream(zipBytes);) { out.write(input, 0, input.length); } return zipBytes.toByteArray(); } GzipEncryptor(BytesEncryptor delegate); @Override byte[] encrypt(byte[] input, int outputOffset, byte[] flags); }
GzipEncryptor implements BytesEncryptor { static byte[] gzip(byte[] input) throws IOException { ByteArrayOutputStream zipBytes = new ByteArrayOutputStream(input.length); try (GZIPOutputStream out = new GZIPOutputStream(zipBytes);) { out.write(input, 0, input.length); } return zipBytes.toByteArray(); } GzipEncryptor(BytesEncryptor delegate); @Override byte[] encrypt(byte[] input, int outputOffset, byte[] flags);  }