public static void isValidCiphertext(
      StreamingAead ags, byte[] plaintext, byte[] associatedData, byte[] ciphertext)
      throws Exception {
    ByteBufferChannel ctChannel = new ByteBufferChannel(ciphertext);
    ReadableByteChannel ptChannel = ags.newDecryptingChannel(ctChannel, associatedData);
    ByteBuffer decrypted = ByteBuffer.allocate(plaintext.length + 1);
    ptChannel.read(decrypted);
    decrypted.flip();
    TestUtil.assertByteBufferContains(plaintext, decrypted);
  }
Encrypts and decrypts a with non-ASCII characters using CharsetEncoders and CharsetDecoders.
java_src/src/main/java/com/google/crypto/tink/testing/StreamingTestUtil.java