How To Create Password Protected Zip File In Python
- Shivam Rohilla
- May 22, 2022
- 3 comments
- 428 Views
<meta name="clckd" content="6301244fb7ed470eb1cd6b8c31d01ac4" />
Hello guys, in this tutorial you'll learn how to make a password-protected zip file using python.
we'll use the python library:-
pip install pyminizip
after installing this library, we use compress() method for creating a zip file.
It's syntax
pyminizip.compress(options)
options are:- inpt = file path,
pre = None, prefix path,
oupt = file name after compressing,
password = abs,
compress_level = 4,
import pyminizip
#file path
inp = "./file.txt"
#pre path
pre = None
#output zip file path
opt = "./fileopt.zip"
#make a password
password = "abc"
#compress level
com_lvl = 5
#Now compressing the file
pyminizip.compress(inp, None, opt, password, com_lvl)
that's it now run the command in your terminal and try to open the file in your pc you will see that file is password protected.
My social media links