@Override
  public byte[] encrypt(final byte[] plaintext) throws GeneralSecurityException {
    ByteBuffer output = ByteBuffer.allocate(NONCE_LENGTH_IN_BYTES + plaintext.length);
    byte[] nonce = Random.randBytes(NONCE_LENGTH_IN_BYTES);
    output.put(nonce); // Prepend nonce to ciphertext output.
    cipher.encrypt(output, nonce, plaintext);
    return output.array();
  }
Constructs a new XChaCha20 cipher with the supplied {@code key}.

@throws IllegalArgumentException when {@code key} length is not {@link
    com.google.crypto.tink.aead.internal.ChaCha20Util#KEY_SIZE_IN_BYTES}.
java_src/src/main/java/com/google/crypto/tink/subtle/XChaCha20.java