Python PyPDF2 — Encrypt a PDF file

Python script that will encrypt a PDF file. To do this we use PyPDF2 which is a Python library that enables users to perform various operations on PDF documents.

In this example the password for the encrypted file will be set to ‘iamlegend’, if you do use this code as part of your own project be sure to change this something appropriate.

Also be sure to subscribe to our YouTube channel for daily coding content.

https://scriptopia.co.uk/2023/01/20/python-pypdf2-encrypt-a-pdf-file/

--

--

Programming - Projects - Source Code available for everything - Scriptopia.co.uk

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store