Skip to main content
Edited title and removed language tag. Improved formatting.
Source Link
martineau
  • 122.4k
  • 29
  • 176
  • 307

Create How to create an encrypted ZIP file in Python?

I am creating an ZIP file with ZipFileZipFile in Python 2.5, it works okOK so far:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()

butBut I couldn't find how to encrypt the files in the ZIP file. I could use system and call PKZIP -sPKZIP -s, but I suppose there must be a more "Pythonic" way. I'm looking for an open source solution.

Create an encrypted ZIP file in Python

I am creating an ZIP file with ZipFile in Python 2.5, it works ok so far:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()

but I couldn't find how to encrypt the files in the ZIP file. I could use system and call PKZIP -s, but I suppose there must be a more "Pythonic" way. I'm looking for an open source solution.

How to create an encrypted ZIP file?

I am creating an ZIP file with ZipFile in Python 2.5, it works OK so far:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()

But I couldn't find how to encrypt the files in the ZIP file. I could use system and call PKZIP -s, but I suppose there must be a more "Pythonic" way. I'm looking for an open source solution.

added 1 character in body
Source Link
piRSquared
  • 291.9k
  • 63
  • 497
  • 638

I'mI am creating an ZIP file with ZipFile in Python 2.5, it works ok so far:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()

but I couldn't find how to encrypt the files in the ZIP file. I could use system and call PKZIP -s, but I suppose there must be a more "Pythonic" way. I'm looking for an open source solution.

I'm creating an ZIP file with ZipFile in Python 2.5, it works ok so far:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()

but I couldn't find how to encrypt the files in the ZIP file. I could use system and call PKZIP -s, but I suppose there must be a more "Pythonic" way. I'm looking for an open source solution.

I am creating an ZIP file with ZipFile in Python 2.5, it works ok so far:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()

but I couldn't find how to encrypt the files in the ZIP file. I could use system and call PKZIP -s, but I suppose there must be a more "Pythonic" way. I'm looking for an open source solution.

added 42 characters in body
Source Link
Bill the Lizard
  • 403.1k
  • 210
  • 570
  • 886
Loading
Source Link
PabloG
  • 26.4k
  • 10
  • 46
  • 59
Loading