From: Daniel Garcia Moreno Date: Fri, 12 Jul 2013 11:18:03 +0000 (+0200) Subject: Fixed AESCrypt.encrypt with no data multiple of bs X-Git-Tag: v2.2~165 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=6d0d526a666110e3a0be7481a1295abae62f99ff;p=python-delta-tar Fixed AESCrypt.encrypt with no data multiple of bs --- diff --git a/deltatar/aescrypto.py b/deltatar/aescrypto.py index c33f1af..3d8066f 100644 --- a/deltatar/aescrypto.py +++ b/deltatar/aescrypto.py @@ -80,13 +80,17 @@ class AESCrypt: ''' self.buf += chunk - - chunk = self.buf - if len(chunk) % self.bs == 0: + if len(self.buf) % self.bs == 0: self.buf = '' - return self.cipher.encrypt(chunk) + return self.cipher.encrypt(self.buf) + + cipher = '' + while len(self.buf) >= self.bs: + chunk = self.buf[:self.bs] + self.buf = self.buf[self.bs:] + cipher += self.cipher.encrypt(chunk) - return '' + return cipher def decrypt(self, buf, end=False): '''