<meta name="clckd" content="6301244fb7ed470eb1cd6b8c31d01ac4" />
Python

How To Create Password Protected Zip File In Python

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,

Program:-


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.

0 Comments
  • No Reviews Yet

Leave a Reply
Please Sign In For Comment.
Login or Signup
Shivam Rohilla
Hi, I'm Shivam Rohilla

Hi! My name is Shivam Rohilla. I am a Full Stack Web Developer, and I'm very passionate and dedicated to my work. With 2 years experience as a professional Full Stack Web Developer.

Follow Me:-

My social media links