def decrypt(key, filename):
chunksize = 64 * 1024
outputFile = filename[:-4]
with open(filename, 'rb') as infile:
filesize = long(infile.read(16))
IV = infile.read(16)
decryptor = AES.new(key, AES.MODE_CBC, IV)
with open(outputFile, 'wb') as outfile:
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
outfile.write(decryptor.decrypt(chunk))
outfile.truncate(filesize)
评论列表
文章目录