|
@@ -17,7 +17,7 @@ class AESCrypt(object):
|
|
cryptor = AES.new(self.key, self.mode, self.key[16:])
|
|
cryptor = AES.new(self.key, self.mode, self.key[16:])
|
|
padlen = AESCrypt.LEN - len(text) % AESCrypt.LEN
|
|
padlen = AESCrypt.LEN - len(text) % AESCrypt.LEN
|
|
padlen = padlen if padlen != 0 else AESCrypt.LEN
|
|
padlen = padlen if padlen != 0 else AESCrypt.LEN
|
|
- text += chr(padlen)*padlen
|
|
|
|
|
|
+ text += (chr(padlen)*padlen).encode('utf8')
|
|
|
|
|
|
return cryptor.encrypt(text)
|
|
return cryptor.encrypt(text)
|
|
|
|
|
|
@@ -43,7 +43,7 @@ if __name__ == '__main__':
|
|
key = md5.hexdigest()
|
|
key = md5.hexdigest()
|
|
cryptor = AESCrypt(key)
|
|
cryptor = AESCrypt(key)
|
|
text = ''.join(map(str, block.contents))
|
|
text = ''.join(map(str, block.contents))
|
|
- written = base64.b64encode(cryptor.encrypt(text))
|
|
|
|
|
|
+ written = base64.b64encode(cryptor.encrypt(text.encode('utf8')))
|
|
|
|
|
|
del block['data-password']
|
|
del block['data-password']
|
|
block.string = written.decode()
|
|
block.string = written.decode()
|