@Test public void testTransform() throws UnsupportedEncodingException { Header encryptionHeader = Header.create("mykey", false, false); BytesEncryptor delegate = SwapBytesTransformer.encryptor(); byte[] input = { 1, 2, 3, 4, 5, 6, 7, 8 }; HeaderEncryptor encryptor = new HeaderEncryptor(delegate, encryptionHeader); byte[] output1 = encryptor.encrypt(input, 0, new byte[1]); assertArrayEquals(new byte[] { 'C', 'C', '1', 10, 0, 'm', 'y', 'k', 'e', 'y', 8, 7, 6, 5, 4, 3, 2, 1 }, output1); byte[] output2 = encryptor.encrypt(input, 1, new byte[1]); assertArrayEquals(new byte[] { 0, 'C', 'C', '1', 10, 0, 'm', 'y', 'k', 'e', 'y', 8, 7, 6, 5, 4, 3, 2, 1 }, output2); }
@Override public byte[] encrypt(byte[] input, int outputOffset, byte[] flags) { flags[0] = header.getFlags(); byte[] output = delegate.encrypt(input, outputOffset + header.size(), flags); header.store(output, outputOffset, flags[0]); return output; }
HeaderEncryptor implements BytesEncryptor { @Override public byte[] encrypt(byte[] input, int outputOffset, byte[] flags) { flags[0] = header.getFlags(); byte[] output = delegate.encrypt(input, outputOffset + header.size(), flags); header.store(output, outputOffset, flags[0]); return output; } }
HeaderEncryptor implements BytesEncryptor { @Override public byte[] encrypt(byte[] input, int outputOffset, byte[] flags) { flags[0] = header.getFlags(); byte[] output = delegate.encrypt(input, outputOffset + header.size(), flags); header.store(output, outputOffset, flags[0]); return output; } HeaderEncryptor(BytesEncryptor delegate, Header header); }
HeaderEncryptor implements BytesEncryptor { @Override public byte[] encrypt(byte[] input, int outputOffset, byte[] flags) { flags[0] = header.getFlags(); byte[] output = delegate.encrypt(input, outputOffset + header.size(), flags); header.store(output, outputOffset, flags[0]); return output; } HeaderEncryptor(BytesEncryptor delegate, Header header); @Override byte[] encrypt(byte[] input, int outputOffset, byte[] flags); }
HeaderEncryptor implements BytesEncryptor { @Override public byte[] encrypt(byte[] input, int outputOffset, byte[] flags) { flags[0] = header.getFlags(); byte[] output = delegate.encrypt(input, outputOffset + header.size(), flags); header.store(output, outputOffset, flags[0]); return output; } HeaderEncryptor(BytesEncryptor delegate, Header header); @Override byte[] encrypt(byte[] input, int outputOffset, byte[] flags);  }