python 加密解压的一点小问题

在使用python解压带密码的zip时,发现了一点问题,就是正确的密码解压错误啊

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'zFile' is not defined
>>> zfile.extractall(pwd="123456")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/zipfile.py", line 1347, in extractall
    self.extract(zipinfo, path, pwd)
  File "/usr/lib/python3.5/zipfile.py", line 1335, in extract
    return self._extract_member(member, path, pwd)
  File "/usr/lib/python3.5/zipfile.py", line 1397, in _extract_member
    with self.open(member, pwd=pwd) as source, \
  File "/usr/lib/python3.5/zipfile.py", line 1244, in open
    raise TypeError("pwd: expected bytes, got %s" % type(pwd))
TypeError: pwd: expected bytes, got <class 'str'>

后来发现zip在使用winrar加密时,需要勾选使用传统压缩,不然会使用winrar默认的CBC的AES-256加密。使用传统加密后python解密成功,做个笔记。

none

发表评论

0条评论

设置
配色方案

布局

现在购买