code: public OutputStream encrypt(OutputStream destination, SecretKey key) throws IOException {
  
          // Basic null check.
          // An empty stream can be encrypted:
          if (destination == null) {
              return null;
          }
  
          Cipher cipher = getCipher();
  
          // Generate an initialisation vector:
          byte[] iv = Generate.byteArray(getIvSize(cipher));
  
          // Get a cipher instance and instantiate the CipherOutputStream:
          initCipher(cipher, Cipher.ENCRYPT_MODE, key, iv);
          CipherOutputStream cipherOutputStream = new CipherOutputStream(destination, cipher);
  
          // The IV can be stored unencrypted at the start of the
          // stream:
          destination.write(iv);
  
          // Return the initialised stream:
          return cipherOutputStream;
      }
docs: This method wraps the destination {@link OutputStream} with a
  {@link CipherOutputStream}.
  <p>
  Typical usage is when you have an InputStream for a source of unencrypted
  data, such as a user-uploaded file, and an OutputStream to write the
  input to disk. You would call this method to wrap the OutputStream and
  use the returned {@link CipherOutputStream} instead to write the data to,
  so that it is encrypted as it is written to disk.
  <p>
  Note that this method writes an initialisation vector to the destination
  OutputStream, so the destination parameter will have some bytes written
  to it before this method returns. These bytes are necessary for initialising
  encryption and a corresponding call to
  {@link #decrypt(InputStream, SecretKey)} will read and filter them out
  from the underlying InputStream before returning it.
  
  @param destination The output stream to be wrapped with a
  {@link CipherOutputStream}.
  @param key         The key to be used to encrypt data written to the returned
  {@link CipherOutputStream}.
  @return A {@link CipherOutputStream}, which wraps the given
  {@link OutputStream}.
  @throws IOException              If an error occurs in writing the initialisation vector to
  the destination stream.
  @throws IllegalArgumentException If the given key is not a valid {@value #CIPHER_ALGORITHM}
  key.
  @see #decrypt(InputStream, SecretKey)