diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-06-28 15:57:48 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-06-28 20:23:46 +0200 |
commit | d8f5e6d74b386045a451ed20a3c250204be8946e (patch) | |
tree | d6fea466ca287e8de33201d4d42b5b12d7c2f75b /module/lib/beaker/crypto/pycrypto.py | |
parent | [Lib] Revert libraries to original status (remove all cosmetics optimizations) (diff) | |
download | pyload-d8f5e6d74b386045a451ed20a3c250204be8946e.tar.xz |
[Lib] Update beaker.py to version 1.6.4
Diffstat (limited to 'module/lib/beaker/crypto/pycrypto.py')
-rw-r--r-- | module/lib/beaker/crypto/pycrypto.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/module/lib/beaker/crypto/pycrypto.py b/module/lib/beaker/crypto/pycrypto.py index a3eb4d9db..6657bff56 100644 --- a/module/lib/beaker/crypto/pycrypto.py +++ b/module/lib/beaker/crypto/pycrypto.py @@ -9,23 +9,26 @@ try: def aesEncrypt(data, key): cipher = aes.AES(key) return cipher.process(data) - + # magic. aesDecrypt = aesEncrypt - + except ImportError: from Crypto.Cipher import AES + from Crypto.Util import Counter def aesEncrypt(data, key): - cipher = AES.new(key) - - data = data + (" " * (16 - (len(data) % 16))) + cipher = AES.new(key, AES.MODE_CTR, + counter=Counter.new(128, initial_value=0)) + return cipher.encrypt(data) def aesDecrypt(data, key): - cipher = AES.new(key) + cipher = AES.new(key, AES.MODE_CTR, + counter=Counter.new(128, initial_value=0)) + return cipher.decrypt(data) + - return cipher.decrypt(data).rstrip() def getKeyLength(): return 32 |