code: @Override
      public void close() throws IOException {
          if (!closed) {
              closed = true;
              try {
                  byte[] buffer = cipher.doFinal();
                  if (buffer != null) {
                      output.write(buffer);
                  }
              } catch (IllegalBlockSizeException | BadPaddingException e) {
                  throw new CipherException(e);
              } finally {
                  if (closeOutput) {
                      super.close();
                  } else {
                      flush();
                  }
              }
          }
      }
docs: {@inheritDoc}