Commit 80fa3cfc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use b32 instead of b16 for shorter encoded key.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43836 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0576a37b
......@@ -56,7 +56,7 @@ from Products.ERP5Security.ERP5UserManager import ERP5UserManager,\
_AuthenticationFailure
from Crypto.Cipher import AES
from base64 import b16decode, b16encode
from base64 import b32decode, b32encode
class AESCipher:
mode = AES.MODE_CFB
......@@ -67,11 +67,11 @@ class AESCipher:
def encrypt(self, login):
encryptor = AES.new(self.encryption_key, self.mode)
return b16encode(encryptor.encrypt(login.ljust(((len(login)-1)/16+1)*16)))
return b32encode(encryptor.encrypt(login.ljust(((len(login)-1)/16+1)*16)))
def decrypt(self, crypted_login):
decryptor = AES.new(self.encryption_key, self.mode)
return decryptor.decrypt(b16decode(crypted_login)).rstrip()
return decryptor.decrypt(b32decode(crypted_login)).rstrip()
# This cipher is weak. Do not use.
class CesarCipher:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment