<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encrypt(self, user_pw='', owner_pw=None, encrypt_128=True, allow_printing=True, allow_commenting=False, document=None):
 """ Encrypt a PDF document to add passwords and restrict permissions. Add a user password that must be entered to view document and a owner password that must be entered to alter permissions and security settings. Encryption keys are 128 bit when encrypt_128 is True and 40 bit when False. By default permissions are restricted to print only, when set to false all permissions are allowed. TODO: Add additional permission parameters :param user_pw: str User password required to open and view PDF document :param owner_pw: str Owner password required to alter security settings and permissions :param encrypt_128: bool Encrypt PDF document using 128 bit keys :param allow_printing: bool Restrict permissions to print only :return: str Encrypted PDF full path """

        document = self.document if document is None else document
        if self.use_receipt:
            self.receipt.add('User pw', user_pw)
            self.receipt.add('Owner pw', owner_pw)
            if encrypt_128:
                self.receipt.add('Encryption key size', '128')
            else:
                self.receipt.add('Encryption key size', '40')
            if allow_printing:
                self.receipt.add('Permissions', 'Allow printing')
            else:
                self.receipt.add('Permissions', 'Allow ALL')
        p = str(Encrypt(document, user_pw, owner_pw, output=add_suffix(self.document_og, 'secured'),
                        bit128=encrypt_128, allow_printing=allow_printing, allow_commenting=allow_commenting,
                        progress_bar_enabled=self.progress_bar_enabled, progress_bar=self.progress_bar))
        if self.use_receipt:
            self.receipt.add('Secured PDF', os.path.basename(p))
        return p