smihica / pyminizip Goto Github PK
View Code? Open in Web Editor NEWTo create a password encrypted zip file in python.
License: Other
To create a password encrypted zip file in python.
License: Other
Hello!
I may have found a security issue in latest version of pyminizip. Following responsible disclosure, is there an email or other private channel where I could share the details?
Thank you
It should be possible to add files to a ZIP archive without creating a temporary file first.
Using python's ordinary ZipFile API, you can create a ZIP archive and then call the open method to create and write to the a new file inside the ZIP file directly. The file will be compressed as it is written.
as far as I can tell, in both the compress and compress_multiple api there is no way to copy source files into subfolders in the destination zip. One side-effect of this, is that different files having duplicate names can result in multiple entries in the archive, but extracts only to one file (race condition).
Some possible implementations:
After pulling my hair out a while, I found my own project was failing to build because it uses pyminizip as a dependency. This github was given for contact:
$ # grep WWW Makefile
WWW= https://github.com/smihica/pyminizip
If you go in its port directory and attempt to build it, you'll see it fail with the following:
/usr/ports/archivers/py-pyminizip
===> Staging for py39-pyminizip-0.2.6
===> py39-pyminizip-0.2.6 depends on package: py39-setuptools>=63.1.0 - found
===> py39-pyminizip-0.2.6 depends on file: /usr/local/bin/python3.9 - found
===> Generating temporary packing list
running install
/usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_ext
running install_lib
writing byte-compilation script '/tmp/tmp8ftpu3kk.py'
/usr/local/bin/python3.9 /tmp/tmp8ftpu3kk.py
removing /tmp/tmp8ftpu3kk.py
running install_egg_info
running egg_info
writing pyminizip.egg-info/PKG-INFO
writing dependency_links to pyminizip.egg-info/dependency_links.txt
writing top-level names to pyminizip.egg-info/top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'pyminizip.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching 'ChangeLog' found under directory 'zlib-1.2.11'
warning: no previously-included files matching 'configure' found under directory 'zlib-1.2.11'
warning: no previously-included files matching 'FAQ' found under directory 'zlib-1.2.11'
warning: no previously-included files matching 'INDEX' found under directory 'zlib-1.2.11'
warning: no previously-included files matching 'Makefile*' found under directory 'zlib-1.2.11'
warning: no previously-included files matching 'make_vms.com' found under directory 'zlib-1.2.11'
warning: no previously-included files matching 'README' found under directory 'zlib-1.2.11'
no previously-included directories found matching 'zlib-1.2.11/amiga'
no previously-included directories found matching 'zlib-1.2.11/as400'
no previously-included directories found matching 'zlib-1.2.11/examples'
no previously-included directories found matching 'zlib-1.2.11/msdos'
no previously-included directories found matching 'zlib-1.2.11/old'
no previously-included directories found matching 'zlib-1.2.11/projects'
no previously-included directories found matching 'zlib-1.2.11/qnx'
no previously-included directories found matching 'zlib-1.2.11/win32'
adding license file 'COPYING.txt'
writing manifest file 'pyminizip.egg-info/SOURCES.txt'
removing '/usr/ports/archivers/py-pyminizip/work-py39/stage/usr/local/lib/python3.9/site-packages/pyminizip-0.2.6-py3.9.egg-info' (and everything under it)
Copying pyminizip.egg-info to /usr/ports/archivers/py-pyminizip/work-py39/stage/usr/local/lib/python3.9/site-packages/pyminizip-0.2.6-py3.9.egg-info
running install_scripts
writing list of installed files to '/usr/ports/archivers/py-pyminizip/work-py39/.PLIST.pymodtmp'
====> Compressing man pages (compress-man)
====> Running Q/A tests (stage-qa)
Warning: 'lib/python3.9/site-packages/pyminizip.cpython-39.so' is not stripped consider trying INSTALL_TARGET=install-strip
or using ${STRIP_CMD}
Error: '/usr/local/lib/python3.9/site-packages/pyminizip.cpython-39.so' is a architecture specific binary file and you have
set NO_ARCH. Either remove NO_ARCH or add 'pyminizip.cpython-39.so' to NO_ARCH_IGNORE.
*** Error code 1
Stop.
make: stopped in /usr/ports/archivers/py-pyminizip
This is on FreeBSD 13.2-RELEASE-p4, which is the most up-to-date stable version at this time. So if it should work correctly on any version of FreeBSD today, this would be it. Any assistance would be great as my code won't build without it. Thanks
Hello,
Forgive me if I'm making mistakes, have not programmed in python for a couple of years now. I suspect the library is not compiled against the processor I'm using, but perhaps I'm wrong. When trying to use pyminizip and running the script I'm making I get the following error:
Traceback (most recent call last):
File "/myproject/main.py", line 2, in <module>
import pyminizip
ImportError: dlopen(/myproject/myproject.env/lib/python3.9/site-packages/pyminizip.cpython-39-darwin.so, 0x0002): tried: '/myproject/myproject.env/lib/python3.9/site-packages/pyminizip.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/pyminizip.cpython-39-darwin.so' (no such file), '/usr/lib/pyminizip.cpython-39-darwin.so' (no such file)
The package is installed with pip:
pip list
Package Version
---------- -------
pathlib 1.0.1
pip 22.0.3
pyminizip 0.2.6
setuptools 60.5.0
System using:
M1 Pro
Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64
code:
import pyminizip
def passwordZip():
password = "something"
pyminizip.compress('./', './file' + '.zip', password)
passwordZip()
This works fine (it creates a password protected ZIP):
pyminizip.compress('file1.docx', 'files.zip', 'password', 5)
But this doesn't (it creates a ZIP without password protection):
pyminizip.compress_multiple(['file1.docx', 'file2.docx'], 'files.zip', 'password', 5)
I’m running pyminizip on Heroku and while it’s working and installing perfectly when the runtime Python is set to 2.7.14 (which is now deprecated by Heroku), I cannot install is under Python 2.7.15.
Getting the following:
In file included from /app/.heroku/python/include/python2.7/Python.h:47:0, from src/py_minizip.c:17:
src/crypt.h:35:53: error: unknown type name ‘z_crc_t’
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^
src/crypt.h:48:52: error: unknown type name ‘z_crc_t’
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab,int c)
^
src/crypt.h:65:71: error: unknown type name ‘z_crc_t’
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^
src/crypt.h:35:12: warning: ‘decrypt_byte’ defined but not used [-Wunused-function]
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^
src/crypt.h:65:13: warning: ‘init_keys’ defined but not used [-Wunused-function]
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^
error: command 'gcc' failed with exit status 1
File "build\bdist.win32\egg\pyminizip.py", line 7, in
File "build\bdist.win32\egg\pyminizip.py", line 6, in bootstrap
ImportError: DLL load failed: The specified module could not be found.
Failed to execute script app
Any glue?
I can build the extension with python2. but for python3, no matter Mingw64 or VC says the same wrong issue.
E:\msys64\mingw64\bin\gcc.exe -shared -s build\temp.win-amd64-3.4\Release\src\py_minizip.o build\temp.win-amd64-3.4\Release\src\zip.o build\temp.win-amd64-3.4\Release\src\ioapi.o build\temp.win-amd64-3.4\Release\zlib123\adler32.o build\temp.win-amd64-3.4\Release\zlib123\compress.o build\temp.win-amd64-3.4\Release\zlib123\crc32.o build\temp.win-amd64-3.4\Release\zlib123\deflate.o build\temp.win-amd64-3.4\Release\zlib123\gzio.o build\temp.win-amd64-3.4\Release\zlib123\infback.o build\temp.win-amd64-3.4\Release\zlib123\inffast.o build\temp.win-amd64-3.4\Release\zlib123\inflate.o build\temp.win-amd64-3.4\Release\zlib123\inftrees.o build\temp.win-amd64-3.4\Release\zlib123\trees.o build\temp.win-amd64-3.4\Release\zlib123\uncompr.o build\temp.win-amd64-3.4\Release\zlib123\zutil.o build\temp.win-amd64-3.4\Release\src\iowin32.o build\temp.win-amd64-3.4\Release\src\pyminizip.def -LE:\prg\py\Anaconda3_64\libs -LE:\prg\py\Anaconda3_64\PCbuild\amd64 -lpython34 -lmsvcr100 -o build\lib.win-amd64-3.4\pyminizip.pyd
build\temp.win-amd64-3.4\Release\src\py_minizip.o:py_minizip.c:(.text+0x8ce): undefined reference to `PyString_Check'
build\temp.win-amd64-3.4\Release\src\py_minizip.o:py_minizip.c:(.text+0x92f): undefined reference to `PyString_AsString'
collect2.exe: error: ld returned 1 exit status
error: command 'E:\\msys64\\mingw64\\bin\\gcc.exe' failed with exit status 1
I don't see any changelog/releases/tags, it is very hard to see what changed in which version. The latest version on PyPi is 0.2.4. So is there anything anywhere which tells what changed in different releases? I have upgraded from 0.2.1 to 0.2.4 and build is failing. Looks like some function signature has changed in pyminizip due with build is failing.
Hello,
On ArchLinux, my pip install pyminizip and setup.py build are ending with the same error :
In file included from /usr/include/python3.6m/Python.h:39:0,
from src/py_minizip.c:17:
src/crypt.h:35:53: error: nom de type « z_crc_t » inconnu
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^~~~~~~
src/crypt.h:48:52: error: nom de type « z_crc_t » inconnu
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab,int c)
^~~~~~~
src/crypt.h:65:71: error: nom de type « z_crc_t » inconnu
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
running build
running build_ext
building 'pyminizip' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC -Isrc -Izlib123 -I/usr/include/python3.6m -c src/py_minizip.c -o build/temp.linux-x86_64-3.6/src/py_minizip.o
In file included from /usr/include/python3.6m/Python.h:39:0,
from src/py_minizip.c:17:
src/crypt.h:35:53: error: nom de type « z_crc_t » inconnu
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^~~~~~~
src/crypt.h:48:52: error: nom de type « z_crc_t » inconnu
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab,int c)
^~~~~~~
src/crypt.h:65:71: error: nom de type « z_crc_t » inconnu
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^~~~~~~
src/py_minizip.c: Dans la fonction « py_compress_multiple »:
src/py_minizip.c:446:14: warning: déclaration implicite de la fonction « PyString_Check »; vouliez-vous utiliser « PyMapping_Check » ? [-Wimplicit-function-declaration]
if (!PyString_Check(str_obj) && !PyUnicode_Check(str_obj)) {
^~~~~~~~~~~~~~
PyMapping_Check
src/py_minizip.c:459:19: warning: déclaration implicite de la fonction « PyString_AsString »; vouliez-vous utiliser « PyBytes_AsString » ? [-Wimplicit-function-declaration]
srcs[i] = PyString_AsString(str_obj);
^~~~~~~~~~~~~~~~~
PyBytes_AsString
src/py_minizip.c:459:17: warning: l'affectation transforme un entier en pointeur sans transtypage [-Wint-conversion]
srcs[i] = PyString_AsString(str_obj);
^
In file included from /usr/include/python3.6m/Python.h:39:0,
from src/py_minizip.c:17:
Au plus haut niveau:
src/crypt.h:65:13: warning: « init_keys » défini mais pas utilisé [-Wunused-function]
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^~~~~~~~~
src/crypt.h:35:12: warning: « decrypt_byte » défini mais pas utilisé [-Wunused-function]
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
^~~~~~~~~~~~
error: command 'gcc' failed with exit status 1
This code, as it's written here, doesn't use AES "out of the box," does it?
As far as I can tell, to get AES, one would need to
HAVE_AES
in the C codeA new high severity vulnerability has been discovered for zlib 1.2.11: GHSA-jc36-42cf-vqwj
Are you thinking in updating this library to a newer version with that vulnerability solved?
Code which work with python 3.9.7 now don't work anymore in python 3.10.0 it always return an error an error which is this one : "expected arguments are compress_multiple([src], [srcpath], dst, pass, level)" but after a 100 hundred recheck everything is correct and work with the past version so I guess it's an issue with the latest python version.
for example
./a.txt
./dir/b.txt
Hi There,
here is my code:
for f in files:
to_zip.append(f)
to_zip_paths.append(path)
pyminizip.compress_multiple(to_zip, to_zip_paths, 'backup_code.zip', '', 4)
This way and with singular file compress works flawlessy, BUT if I change the last line adding a password like
pyminizip.compress_multiple(to_zip, to_zip_paths, 'backup_code.zip', '1234', 4)
it acts really weird like it is asking the password for EACH FILE inside the folder; and it works just for the first one, if I type for the second it doesn't, look:
What's causing this?
Thanks
N.B. Even in the cases it works I get this warning
DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
pyminizip.compress_multiple(...
Hi,
Have some doubts. Please let me know the answers for the following questions-
what encryption algorithm is used to encrypt the zip file with password?
What is the level of encryption?
Only the source is available on pypi.python.org, so users must first install 'zlib' before running pip install pyminizip
. If pyminizip were also distributed as a binary wheel package, then that extra manual step would be eliminated. This would be helpful for people installing pyminizip in a virtualenv or for downstream PIP projects that depend on pyminizip.
This could be done by running the following on a system with zlib already installed:
pip install twine
pip install wheel
python setup.py sdist bdist_wheel
twine upload dist/*
Thank you so much for this wrapper. I've been able to use pip to install on ubuntu, but I haven't been able to get it to install on windows due to multiple compiler errors.
I've tried to install the zlib library on windows (gnuwin32), but I'm not sure pyminizip/setup.py knows how to find the source files it needs from that library.
Here is one error log from Pycharm package installer:
Here's the error log:
Install packages failed: Error occurred when installing package pyminizip.
The following command was executed:
packaging_tool.py install --build-dir C:\Users\Pylee\AppData\Local\Temp\pycharm-packaging2473906546786097704.tmp pyminizip
The error output of the command:
Downloading/unpacking pyminizip
Running setup.py egg_info for package pyminizip
Installing collected packages: pyminizip
Running setup.py install for pyminizip
building 'pyminizip' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc "-ID:\Program Files (x86)\Python27\include" "-ID:\Program Files (x86)\Python27\PC" /Tcsrc/py_minizip.c /Fobuild\temp.win32-2.7\Release\src/py_minizip.obj
py_minizip.c
c:\users\pylee\appdata\local\temp\pycharm-packaging2473906546786097704.tmp\pyminizip\src\zip.h(43) : fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
Complete output from command "D:\Program Files (x86)\Python27\python.exe" -c "import setuptools;file='C:\Users\Pylee\AppData\Local\Temp\pycharm-packaging2473906546786097704.tmp\pyminizip\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record c:\users\pylee\appdata\local\temp\pip-d5vjjc-record\install-record.txt:
running install
running build
running build_ext
building 'pyminizip' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc "-ID:\Program Files (x86)\Python27\include" "-ID:\Program Files (x86)\Python27\PC" /Tcsrc/py_minizip.c /Fobuild\temp.win32-2.7\Release\src/py_minizip.obj
py_minizip.c
c:\users\pylee\appdata\local\temp\pycharm-packaging2473906546786097704.tmp\pyminizip\src\zip.h(43) : fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
Command "D:\Program Files (x86)\Python27\python.exe" -c "import setuptools;file='C:\Users\Pylee\AppData\Local\Temp\pycharm-packaging2473906546786097704.tmp\pyminizip\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record c:\users\pylee\appdata\local\temp\pip-d5vjjc-record\install-record.txt failed with error code 1 in C:\Users\Pylee\AppData\Local\Temp\pycharm-packaging2473906546786097704.tmp\pyminizip
Storing complete log in C:\Users\Pylee\AppData\Roaming\pip\pip.log
pyminizip.compress("D:\py\测试文件.txt", None, "D:\py\test.zip", "password", 5)
it will give the error :
Exception "unhandled OSError"
error in opening D:\py\测试文件.txt for reading
I am writing my coursework (a digital Fort Knox) and I was using PyMinizip to encrypt a ZIP archive.
Source code: https://pastebin.com/PcpvSUZ3
For some reason, the arguments passed aren't working. This is the output:
pyminizip.compress(filearray2, zipName, pforzip[0], 5)
ValueError: expected arguments are compress(src, srcpath, dst, pass, level)
filearray2: ['seamless.txt']
zipName: zip.zip
pforzip[0]: user0
Process finished with exit code 0
I specified the file, zip destination name and the password and it says it is still invalid...
Help?!?!
When running the compress_multiple
function with zlib 1.3.* it crashes, even when runningnwith the same parameters and on the same machine as before, but simply updating zlib.
Hi!
Currently, the progress
argument of compress_multiple
is checked with PyFunction_Check
.
Most of the time, it is fine. But there are cases where this check fails (e.g. partial
, or compiled function with Python compiler like SCons
).
I guess that any callable would be good for pyminizip right? So why not checking the progress
object with PyCallable_Check
which has the same signature than PyFunction_Check
int PyFunction_Check(PyObject *o)
Return true if o is a function object (has type PyFunction_Type). The parameter must not be NULL.
vs
int PyCallable_Check(PyObject *o)
Determine if the object o is callable. Return 1 if the object is callable and 0 otherwise. This function always succeeds.
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Type of progress is <class 'compiled_function'>
Exception while creating archive 20230913-203728.zip: progress must be function or None
Traceback (most recent call last):
File "zipper.py", line 54, in compress
pyminizip.compress_multiple(
ValueError: progress must be function or None
Type of progress is <class 'functools.partial'>
Exception while creating archive 20230913-204749.zip: progress must be function or None
Traceback (most recent call last):
File "zipper.py", line 52, in compress
pyminizip.compress_multiple(
ValueError: progress must be function or None
Dear @smihica,
Can you update the code?
There is a zlib 1.3 and a CVE fix in more (you can use current git devel branch):
Note that there are other CVE fixes in previous builds too.
Example:
Thanks in advance.
This is the error when you do pip install pyminizip
In file included from src/zip.c:66:0:
src/crypt.h:34:23: error: conflicting types for ‘z_crc_t’
typedef unsigned long z_crc_t;
^
In file included from /usr/include/zlib.h:34:0,
from src/zip.c:36:
/usr/include/x86_64-linux-gnu/zconf.h:406:17: note: previous declaration of ‘z_crc_t’ was here
typedef Z_U4 z_crc_t;
^
src/zip.c:201:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
local linkedlist_datablock_internal* allocate_new_datablock OF(());
^
src/zip.c:202:38: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
local linkedlist_datablock_internal* allocate_new_datablock()
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
This is on Debian Jessie. I've also tried to install zlib1g package and it was the same.
When using pyminizip.compress_multiple, the input password does not work.
While unzipping in loop , it throws error , here is code import os
import pyminizip
from zipfile import ZipFile
def split_file(input_file, output_folder, chunk_size, password):
password_bytes = password.encode('utf-8') # Encode the password as bytes
# Ensure the output folder exists
os.makedirs(output_folder, exist_ok=True)
part_number = 1
with open(input_file, 'rb') as infile:
while True:
chunk = infile.read(chunk_size)
if not chunk:
break
# Get the original file extension
file_extension = os.path.splitext(input_file)[-1]
# Create the part filename with the original extension
part_filename = os.path.join(output_folder, f'part{part_number:04}.zip')
# Write the chunk to a temporary file
temp_filename = 'temp_file.dat'
with open(temp_filename, 'wb') as temp_file:
temp_file.write(chunk)
# Create a password-encrypted ZIP file using pyminizip
pyminizip.compress(temp_filename, None, part_filename, password, 0)
# Remove the temporary file
os.remove(temp_filename)
part_number += 1
def join_parts(part_files, output_path, password):
password_bytes = password.encode('utf-8') # Encode the password as bytes
# Create a temporary directory for extraction
extraction_dir = 'temp_extraction'
os.makedirs(extraction_dir, exist_ok=True)
try:
for index, part_file in enumerate(part_files):
print(f'Extracting {part_file}...')
# Extract the ZIP file using pyminizip into the temporary directory
print(os.path.exists(part_file) , 'FILE EXIST')
pyminizip.uncompress(part_file, password, extraction_dir, 0)
extracted_file_path = os.path.join(extraction_dir, 'data')
# Check if the extracted file exists
if os.path.exists(extracted_file_path):
# Read the content of the extracted file
with open(extracted_file_path, 'rb') as extracted_file:
part_data = extracted_file.read()
# Write the extracted data to the output file
with open(output_path, 'ab') as output_file:
output_file.write(part_data)
else:
print(f'Error: Extracted file not found for {part_file}')
finally:
pass
print(f'File joined successfully.')
def test_run():
input_file = 'sample.mp4' # Replace with the path to your input file
output_folder = 'output_parts' # Folder to store split parts
chunk_size = 1 * 1024 * 1024 # 5 MB
password = 'your_password' # Replace with your desired password
# Ensure the output folder exists
os.makedirs(output_folder, exist_ok=True)
# Specify the index to resume splitting from (e.g., None or 20,000,000 bytes)
start_index = None # Change to the desired start index, or leave as None to start from the beginning
# Specify the byte progress for resuming (e.g., None or 2,000,000 bytes)
byte_progress = None # Change to the desired byte progress, or leave as None to start from the beginning
# Split the file into parts, optionally resuming from a specific index and byte progress
split_file(input_file, output_folder, chunk_size, password)
# List of part files (you can modify this list as needed)
part_files = sorted([
os.path.join(output_folder, filename)
for filename in os.listdir(output_folder)
if filename.startswith('part') and filename.endswith('.zip')
])
# Specify the output file for joining the parts
output_file = 'output_combined.mp4' # Replace with your desired output file name
# Specify the index to resume joining from (e.g., None or 2)
start_index = None # Change to the desired start index, or leave as None to start from the beginning
# Specify the byte progress for resuming (e.g., None or 2,000,000 bytes)
byte_progress = None # Change to the desired byte progress, or leave as None to start from the beginning
# Join the parts to recreate the original file, optionally resuming from a specific index and byte progress
join_parts(part_files, output_file, password)
print(f'File split into {len(part_files)} parts and then joined successfully.')
if name == 'main':
test_run()
test_run()
It would be better that pyminizip.compress() accept file-like object, like BytesIO, StringIO. So we could do compression in memory.
pyminizip.compress_multiple([u'a.txt', 'b.txt'], ['E:', 'E:'], "file.zip", "1233", 4)
but,I get this:
pyminizip.compress_multiple(["a.txt","b.txt"],[r"E:\",r"E:\"],"abc.zip",password,6)
OSError: error in opening a.txt for reading
I don't know what's the point![2. src file LIST prefix path (list) or ]
Thank you very much!
DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
pyminizip.compress_multiple(<blah>)
I'm assuming this is an internal deprecation warning, and not a usage issue.
Relates to https://bugs.python.org/issue36381
I'm using Python 3.8.6 on Windows 10 Enterprise.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.