The method which is used is encrypt. Below you can find it's header and the documentation:

def encrypt(self, user_pwd, owner_pwd = None, use_128bit = True):
"""
Encrypt this PDF file with the PDF Standard encryption handler.
:param str user_pwd: The "user password", which allows for opening
and reading the PDF file with the restrictions provided.
:param str owner_pwd: The "owner password", which allows for
opening the PDF files without any restrictions. By default,
the owner password is the same as the user password.
:param bool use_128bit: flag as to whether to use 128bit
encryption. When false, 40bit encryption will be used. By default,
this flag is on.
"""

user_pwd – The "user password", which allows for opening
and reading the PDF file with the restrictions provided.
owner_pwd – he "owner password", which allows for
opening the PDF files without any restrictions. By default,
the owner password is the same as the user password.
use_128bit – Decides which encryption to use128bit or 40bit.

You can control the pages in the output document like starting from page X:

for i in range(1, input_stream.getNumPages()):
output.addPage(input_stream.getPage(i))

or removing some of the last pages by:

for i in range(0, input_stream.getNumPages() - 1):
output.addPage(input_stream.getPage(i))