Fixed AESCrypt.encrypt with no data multiple of bs
authorDaniel Garcia Moreno <danigm@wadobo.com>
Fri, 12 Jul 2013 11:18:03 +0000 (13:18 +0200)
committerDaniel Garcia Moreno <danigm@wadobo.com>
Fri, 12 Jul 2013 11:18:03 +0000 (13:18 +0200)
deltatar/aescrypto.py

index c33f1af..3d8066f 100644 (file)
@@ -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):
         '''