7Z Archive : test.7z
Compress Software : BandiZip 6.14,build 25403,2018-06-19,x64
Runtime : Python 3.6.6 on Win32
OS : Windows 10 x64 build 1803
Decompress the archive without password encrypt,works fine,all file successfully decompressed,
But when encrypt the archive with password "1234",py7zlib given the traceback:
Traceback (most recent call last):
File ".\mainPrg.py", line 8, in
archiveClass.decompressArchive(archiveClass.openArchive("test.7z","1234"))
File "C:\Users\Vinyl\Desktop\py7ztest\archive7zip.py", line 33, in decompressArchive
if (not cf.checkcrc()):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pylzma-0.0.0.dev0-py3.6-win32.egg\py7zlib.py", line 780, in checkcrc
data = self.read()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pylzma-0.0.0.dev0-py3.6-win32.egg\py7zlib.py", line 632, in read
data = getattr(self, decoder)(coder, data, level, num_coders)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pylzma-0.0.0.dev0-py3.6-win32.egg\py7zlib.py", line 772, in _read_7z_aes256_sha256
result = cipher.decrypt(input)
TypeError: data must be a multiple of 16 bytes, got 807
My Code :
archive7zip.py
`#coding:utf-8
import pylzma
import time
import os
from py7zlib import Archive7z,NoPasswordGivenError,WrongPasswordError,UTC
class Archive7Zip(object):
def init(self):
self.__openedFile = []
def openArchive(self,fileName,password = None):
archive = open(fileName,"rb")
self.__openedFile.append(archive)
archive = Archive7z(archive,password)
return archive
def decompressArchive(self,archive):
fileNames = archive.getnames()
for fileName in fileNames:
paths = os.path.split(fileName)
# print (paths)
for i in range(len(paths) - 1):
if (len(paths) == 1):break
try:
os.makedirs(paths[i])
except FileExistsError:
break
cf = archive.getmember(fileName)
if (not cf.checkcrc()):
print ("Check CRC Failed : %s" % filename)
continue
with open(fileName,"wb+") as f:
f.write(cf.read())
f.close()
print ("Decompress \"%s\" Successfully." % fileName)
This archive created by bandizip with maximum compress level.When I switched to 7-zip,the problem not solved.
But using no compress can solve this problem.
7Z Archive : test.7z Compress Software : BandiZip 6.14,build 25403,2018-06-19,x64 Runtime : Python 3.6.6 on Win32 OS : Windows 10 x64 build 1803 Decompress the archive without password encrypt,works fine,all file successfully decompressed, But when encrypt the archive with password "1234",py7zlib given the traceback:
My Code :
archive7zip.py `#coding:utf-8
import pylzma import time import os from py7zlib import Archive7z,NoPasswordGivenError,WrongPasswordError,UTC
class Archive7Zip(object): def init(self): self.__openedFile = []
`
main.py `# coding:utf-8
from archive7zip import Archive7Zip
archiveClass = Archive7Zip()
archiveClass.decompressArchive(archiveClass.openArchive("test.7z","1234")) `
Can someone help me?I'm not good at English.
This is the archive file,decompress it for "test.7z",password = 1234 Archive.zip