private static ReadableByteChannel createCiphertextChannel(
      final StreamingAead ags,
      final ReadableByteChannel plaintext,
      final byte[] associatedData,
      final int chunkSize)
      throws Exception {
    PipedOutputStream output = new PipedOutputStream();
    PipedInputStream result = new PipedInputStream(output);
    final WritableByteChannel ciphertext = Channels.newChannel(output);
    new Thread(
            new Runnable() {
              @Override
              public void run() {
                encryptWithChannel(ags, plaintext, ciphertext, associatedData, chunkSize);
              }
            })
        .start();
    return Channels.newChannel(result);
  }
Constructs a ReadableByteChannel with ciphertext from a ReadableByteChannel. The method
constructs a new thread that is used to encrypt the plaintext. TODO(bleichen): Using
PipedInputStream may have performance problems.
java_src/src/main/java/com/google/crypto/tink/testing/StreamingTestUtil.java