diff options
Diffstat (limited to 'passlib/handlers/oracle.py')
-rw-r--r-- | passlib/handlers/oracle.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/passlib/handlers/oracle.py b/passlib/handlers/oracle.py index a094f37..92f1767 100644 --- a/passlib/handlers/oracle.py +++ b/passlib/handlers/oracle.py @@ -10,8 +10,6 @@ import logging; log = logging.getLogger(__name__) # site # pkg from passlib.utils import to_unicode, xor_bytes -from passlib.utils.compat import irange, u, \ - uascii_to_str, unicode, str_to_uascii from passlib.crypto.des import des_encrypt_block import passlib.utils.handlers as uh # local @@ -41,7 +39,7 @@ def des_cbc_encrypt(key, value, iv=b'\x00' * 8, pad=b'\x00'): """ value += pad * (-len(value) % 8) # null pad to multiple of 8 hash = iv # start things off - for offset in irange(0,len(value),8): + for offset in range(0, len(value), 8): chunk = xor_bytes(hash, value[offset:offset+8]) hash = des_encrypt_block(key, chunk) return hash @@ -141,7 +139,7 @@ class oracle11(uh.HasSalt, uh.GenericHandler): #=================================================================== # methods #=================================================================== - _hash_regex = re.compile(u("^S:(?P<chk>[0-9a-f]{40})(?P<salt>[0-9a-f]{20})$"), re.I) + _hash_regex = re.compile(u"^S:(?P<chk>[0-9a-f]{40})(?P<salt>[0-9a-f]{20})$", re.I) @classmethod def from_string(cls, hash): @@ -154,14 +152,14 @@ class oracle11(uh.HasSalt, uh.GenericHandler): def to_string(self): chk = self.checksum - hash = u("S:%s%s") % (chk.upper(), self.salt.upper()) - return uascii_to_str(hash) + hash = u"S:%s%s" % (chk.upper(), self.salt.upper()) + return hash def _calc_checksum(self, secret): - if isinstance(secret, unicode): + if isinstance(secret, str): secret = secret.encode("utf-8") chk = sha1(secret + unhexlify(self.salt.encode("ascii"))).hexdigest() - return str_to_uascii(chk).upper() + return chk.upper() #=================================================================== # eoc |