我有一个问题,如何加密压缩的二进制大对象类型的zip。由于某些原因,我不能使用chilkat模块,zipfile模块只提供解密,所以我不知道用什么来加密带有密钥的zips。
你能给我一些建议如何解决这个问题吗?
理想的解决方案应该如下所示:
blob_info = blobstore.BlobInfo.all()[0] #lets say we want to read the first blob we find
blob_reader = blobstore.BlobReader(blob_info.key())
file = zipfile.ZipFile(blob_reader, 'r')
data = file.read(file.namelist()[0])
output = StringIO.StringIO()
outfile = zipfile.ZipFile(output, "w")
outfile.writestr(file.namelist()[0], data)
outfile.setpassword('testpass') #it would be nice if there was a module that could set pass like this, .setpassword() only works with decryption
outfile.close()
outputStream = files.blobstore.create(mime_type='application/zip', _blobinfo_uploaded_filename = file.namelist()[0].split('.')[0] + '.zip')
with files.open(outputStream, 'a') as f:
f.write(output.getvalue())
files.finalize(outputStream)发布于 2011-09-15 21:34:58
首先,请允许我说zip加密是脆弱和过时的。如果您需要强大的安全性,就不应该依赖它。这一点已经在许多论文中得到了证明(谷歌表示,最受欢迎的是Eli Biham和Paul C.Kocher的“已知的对PKZIP流密码的明文攻击”)。
其次,GAE只适用于纯python的库。也许你不能使用chilkat,因为它是一个C库。
第三,纯python的zip文件加密/解密将会慢得像地狱一样慢,而且你可能会在GAE中遇到CPU问题……
也许你应该寻找另一种方法来做这件事?
问候
https://stackoverflow.com/questions/7431521
复制相似问题