Skip to content
Advertisement

Python: password protect PDFs with random passwords and save file name-password

I am pretty new to Python, what I am looking for is to bulk protect a series of PDFs files within a folder, each file with a unique password randomly generated – these file name-password combinations should then be saved somewhere (potentially CSV file).

Currently using a code that protects all the files within the folder with the same password user-defined. But I cannot manage to protect them with different autogenerated passwords for each PDFs.

thanks a lot in advance for your help

JavaScript

Advertisement

Answer

See the below code to get the desired output with auto-generated password for each pdf:

Edited Implemented in your code:

JavaScript

Code:

JavaScript

Let me know if you have any questions :)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement