summaryrefslogtreecommitdiff
path: root/passlib/handlers/mysql.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/handlers/mysql.py')
-rw-r--r--passlib/handlers/mysql.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/passlib/handlers/mysql.py b/passlib/handlers/mysql.py
index 4a71253..0958c46 100644
--- a/passlib/handlers/mysql.py
+++ b/passlib/handlers/mysql.py
@@ -30,8 +30,6 @@ from warnings import warn
# site
# pkg
from passlib.utils import to_native_str
-from passlib.utils.compat import bascii_to_str, unicode, u, \
- byte_elem_value, str_to_uascii
import passlib.utils.handlers as uh
# local
__all__ = [
@@ -65,7 +63,7 @@ class mysql323(uh.StaticHandler):
def _calc_checksum(self, secret):
# FIXME: no idea if mysql has a policy about handling unicode passwords
- if isinstance(secret, unicode):
+ if isinstance(secret, str):
secret = secret.encode("utf-8")
MASK_32 = 0xffffffff
@@ -78,11 +76,11 @@ class mysql323(uh.StaticHandler):
for c in secret:
if c in WHITE:
continue
- tmp = byte_elem_value(c)
+ tmp = c
nr1 ^= ((((nr1 & 63)+add)*tmp) + (nr1 << 8)) & MASK_32
nr2 = (nr2+((nr2 << 8) ^ nr1)) & MASK_32
add = (add+tmp) & MASK_32
- return u("%08x%08x") % (nr1 & MASK_31, nr2 & MASK_31)
+ return u"%08x%08x" % (nr1 & MASK_31, nr2 & MASK_31)
#===================================================================
# eoc
@@ -102,7 +100,7 @@ class mysql41(uh.StaticHandler):
# class attrs
#===================================================================
name = "mysql41"
- _hash_prefix = u("*")
+ _hash_prefix = u"*"
checksum_chars = uh.HEX_CHARS
checksum_size = 40
@@ -115,9 +113,9 @@ class mysql41(uh.StaticHandler):
def _calc_checksum(self, secret):
# FIXME: no idea if mysql has a policy about handling unicode passwords
- if isinstance(secret, unicode):
+ if isinstance(secret, str):
secret = secret.encode("utf-8")
- return str_to_uascii(sha1(sha1(secret).digest()).hexdigest()).upper()
+ return sha1(sha1(secret).digest()).hexdigest().upper()
#===================================================================
# eoc