code: public OutputStream encryptFile(OutputStream outputStream, String passPhrase, String cipher) throws IOException {
      try {
        if (Security.getProvider(PROVIDER_NAME) == null) {
          Security.addProvider(new BouncyCastleProvider());
        }
  
        PGPEncryptedDataGenerator cPk = new PGPEncryptedDataGenerator(
            new JcePGPDataEncryptorBuilder(symmetricKeyAlgorithmNameToTag(cipher))
                .setSecureRandom(new SecureRandom())
                .setProvider(PROVIDER_NAME));
        cPk.addMethod(new JcePBEKeyEncryptionMethodGenerator(passPhrase.toCharArray()).setProvider(PROVIDER_NAME));
  
        OutputStream cOut = cPk.open(outputStream, new byte[BUFFER_SIZE]);
  
        PGPLiteralDataGenerator literalGen = new PGPLiteralDataGenerator();
        OutputStream _literalOut =
            literalGen.open(cOut, PGPLiteralDataGenerator.BINARY, PAYLOAD_NAME, new Date(), new byte[BUFFER_SIZE]);
  
        return new ClosingWrapperOutputStream(_literalOut, cOut, outputStream);
      } catch (PGPException e) {
        throw new IOException(e);
      }
    }
docs: Taking in an input {@link OutputStream} and a passPhrase, return an {@link OutputStream} that can be used to output
  encrypted output to the input {@link OutputStream}.
  @param outputStream the output stream to hold the ciphertext {@link OutputStream}
  @param passPhrase pass phrase
  @param cipher the symmetric cipher to use for encryption. If null or empty then a default cipher is used.
  @return {@link OutputStream} to write content to for encryption
  @throws IOException